コード例 #1
0
from rectangle import Rectangle, Square, Circle

#далее создаем 2 прямоугольника

rect_1 = Rectangle(3, 4)
rect_2 = Rectangle(12, 5)
#вывод площади наших двух прямоугольников
print(rect_1.get_area(), rect_2.get_area())

square_1 = Square(5)
square_2 = Square(10)

print(square_1.get_area_square(), square_2.get_area_square())

circle_1 = Circle(5)
circle_2 = Circle(10)

figures = [rect_1, rect_2, square_1, square_2, circle_1, circle_2]

for figure in figures:
    if isinstance(figure, Square):
        print(figure.get_area_square())
    elif isinstance(figure, Circle):
        print(figure.get_area_circle())
    else:
        print(figure.get_area())
コード例 #2
0
from rectangle import Rectangle, Square, Circle

r1 = Rectangle(10, 5)
r2 = Rectangle(15, 5)

print(r1.get_area())
print(r2.get_area())

s1 = Square(5)
s2 = Square(3)

print(s1.get_area_square(), s2.get_area_square())

c1 = Circle(6)
c2 = Circle(10)

print(c1.get_area_circle(), c2.get_area_circle())

figures = [r1, r2, s1, s2, c1, c2]

for figure in figures:
    if isinstance(figure, Square):
        print(figure.get_area_square())
    elif isinstance(figure, Circle):
        print(figure.get_area_circle())
    else:
        print(figure.get_area())
コード例 #3
0
from rectangle import Rectangle, Square, Circle
rect_1 = Rectangle(3,4)
rect_2 = Rectangle(12,5)

print("Площадь первого прямоугольника = ", rect_1.get_area())
print("Площадь второго прямоугольника = ",rect_2.get_area())

square_1 = Square(5)
square_2 = Square(10)

print("Площадь первого квадрата = ", square_1.get_area_square(),
      "Площадь второго квадрата = ", square_2.get_area_square())

radius_1 = Circle(8)
radius_2 = Circle(15)
print("Площадь первого круга = ", radius_1.get_area_circle(),
      "Площадь второго круга = ", radius_2.get_area_circle())

figures = [rect_1, rect_2, square_1, square_2, radius_1, radius_2]
for figure in figures:
    if isinstance(figure, Square):
        print(figure.get_area_square())
    elif isinstance(figure, Circle):
        print(figure.get_area_circle())
    else:
        print(figure.get_area())

コード例 #4
0
from rectangle import Rectangle, Square, Circle

rect1 = Rectangle(4, 5)
rect2 = Rectangle(3, 5)
print(rect1.get_area())
print(rect2.get_area())

square1 = Square(5)
square2 = Square(9)

print(square1.get_area_square(), square2.get_area_square())

circle = Circle(6)
print(circle.get_area_circle())

figures = [rect1, rect2, square1, square2, circle]
for figure in figures:
    if isinstance(figure, Square):
        print(figure.get_area_square())
    elif isinstance(figure, Circle):
        print(figure.get_area_circle())

    else:
        print(figure.get_area())
コード例 #5
0
from rectangle import Rectangle, Square, Circle

# далее создаем два прямоугольника

rect_1 = Rectangle(3, 4)
rect_2 = Rectangle(12, 5)
# вывод площади наших двух прямоугольников
print(rect_1.get_area(), '\n',
      rect_2.get_area())

square_1 = Square(5)
square_2 = Square(10)

print(square_1.get_area_square(), '\n',
      square_2.get_area_square())

circle_1 = Circle(7)
circle_2 = Circle(10)

print(circle_1.get_area_circle(), '\n',
      circle_2.get_area_circle())