import math
class Figure():
"'the determination of the parameters of the figure"'
def __init__(self, radius, lenght, height):
self.radius = radius
self.lenght = lenght
self.height = height
class Circle(Figure):
"'calculate the parameters of a circle"'
def __init__(self, radius, lenght=0):
super().__init__(radius, lenght)
self.pi = math.pi
def areaCircle(self):
"""the area of a circle"""
area = self.pi * self.radius ** 2
print(area)
def lenghtCircle(self):
"""circumference"""
lenght = 2 * self.pi* self.radius
print(lenght)
class Rectangle(Figure):
"""calculate the parameters of the rectangle"""
def __init__(self, lenght, height, radius = 0):
super().__init__(radius,lenght, height)
def areaRectangle(self):
"""the area of a rectangle"""
area = self.lenght * self.height
print(area)
def perimeterRectangle(self):
"""perimeter of rectangle"""
perimeter = 2* (self.height+self.lenght)
print(perimeter)
my_rectangle = Rectangle(3,4)
my_rectangle.perimeterRectangle()
Find more questions by tags Python