pythonproblem
pythonproblem
He coloured all the shapes and submitted to his teacher. His teacher wants him to write a program in
python to find the area of all the shapes. Suggest john with object oriented techniques to solve the
problem.
Algorithm:
class Shapes:
def area(self):
pass
class Circle(Shapes):
self.radius = radius
def area(self):
class Rectangle(Shapes):
self.width = width
self.height = height
def area(self):
class Triangle(Shapes):
self.base = base
self.height = height
def area(self):
a = Circle(2)
b = Rectangle(3,4)
c = Triangle(5,6)
print(a.area())
print(b.area())
print(c.area())
output
12.56
12
15.0