2 Respostas
+ 17
class Juice:
def __init__(self, name, capacity):
self.name = name
self.capacity = capacity
def __add__(self, other):
x = self.name +'&'+ other.name
y = self.capacity + other.capacity
return Juice(x,y)
def __str__(self):
return str(self.name)+ ' (' + str(self.capacity) + 'L)'
a = Juice('Orange', 1.5)
b = Juice('Apple', 2.0)
result = a + b
print(result)
+ 1
Привет всем.
Помогите решить практическую задачу номер 24.2 в разделе Control flow