Skip to content

Commit 0e67c5d

Browse files
Create 7_superFunctions.py
1 parent 86999dc commit 0e67c5d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class Rectangle:
2+
def __init__(self,length,width):
3+
self.length = length
4+
self.width = width
5+
6+
class Square(Rectangle):
7+
def __init__(self,length,width):
8+
super().__init__(length,width)
9+
def area(self):
10+
return self.length * self.width
11+
12+
class Cube(Rectangle):
13+
def __init__(self,length, width, height):
14+
super().__init__(length, width)
15+
self.height = height
16+
def volume(self):
17+
return self.length * self.width * self.width
18+
19+
square_obj = Square(3,3)
20+
cube_obj = Cube(3,3,3)
21+
a = square_obj.area()
22+
b = cube_obj.volume()
23+
print(a)
24+
print(b)
25+
26+
"""
27+
Output:
28+
9
29+
27
30+
"""

0 commit comments

Comments
 (0)