-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSUPER().txt
More file actions
42 lines (36 loc) · 1.28 KB
/
Copy pathSUPER().txt
File metadata and controls
42 lines (36 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Shape:
def __init__(self,color,filled):
self.color = color
self.filled= filled
def describe(self):
print(f"it is <<{self.color}>> and {"<<is filled>>" if self.filled else "<<not filled>>"}")
class Circle (Shape):
def __init__(self,color,filled,raduis):
super().__init__(color,filled)
self.raduis=raduis
def describe(self):
super().describe()
print(f"it is circle with area of {3.14*pow(self.raduis,2)} cm^2")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>")
class Square (Shape):
def __init__(self,color,filled,width):
super().__init__(color,filled)
self.width= width
def describe(self):
super().describe()
print(f"it is square with area of {pow(self.width,2)} cm^2")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>")
class Triangle (Shape) :
def __init__(self,color,filled,width,heigth):
super().__init__(color,filled)
self.width=width
self.height=heigth
def describe(self):
super().describe()
print(f"it is Traingle with area of{(self.height * self.width)/2} cm^2")
C=Circle("Red",True,3)
S=Square("Black",False,5)
T=Triangle("Bleu",True,6,8 )
C.describe()
S.describe()
T.describe()