-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoop.py
More file actions
40 lines (29 loc) · 686 Bytes
/
oop.py
File metadata and controls
40 lines (29 loc) · 686 Bytes
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
'''OOP
'''
import math
class Shape():
def __init__(self):
self.color="Blue"
self.sides=0
def area(self):
return 0
class square(Shape):
def __init__(self,w,c):
Shape.__init__(self)
self.width=w
self.color=c
def area(self):
return self.width**2
class circle(Shape):
def __init__(self,r,c):
Shape.__init__(self)
self.radius=r
self.color=c
def area(self):
return math.pi * (self.radius**2)
sq1= square(5,"BLue")
sq2=square(25,"Red")
c=circle(7,"Green")
print("Sq1",sq1.area())
print("Sq2",sq2.area())
print("Circle",c.area())