python exercises with solutions init method

Solutions on MaxInterview for python exercises with solutions init method by the best coders in the world

showing results for - "python exercises with solutions init method"
Giorgio
12 Jan 2019
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