1>>> class Triangle(object):
2... def __init__(self,angle1,angle2,angle3):
3... self.angle1=angle1
4... self.angle2=angle2
5... self.angle3=angle3
6...
7... number_of_sides=3
8... def check_angles(self):
9... if self.angle1+self.angle2+self.angle3 ==180:
10... return True
11... else:
12... return False
13...
14>>> class Equilateral(Triangle):
15... angle = 60
16... def __init__(self):
17... self.angle1 = self.angle2 = self.angle3 = self.angle
18...
19>>> my_triangle=Triangle(90,30,60)
20>>>
21>>> print my_triangle.number_of_sides
223
23>>> print my_triangle.check_angles()
24True
25>>>
26
27>>>
28
1class MinimumBalanceAccount(BankAccount):
2 def __init__(self, minimum_balance):
3 BankAccount.__init__(self)
4 self.minimum_balance = minimum_balance
5
6 def withdraw(self, amount):
7 if self.balance - amount < self.minimum_balance:
8 print('Sorry, minimum balance must be maintained.')
9 else:
10 BankAccount.withdraw(self, amount)
11