Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def circle(r):
- s = math.pi * r**2
- return s
- def rectangle(a, b):
- s= a*b
- return s
- def triangle(a, b, c):
- p = (a+b+c)/2
- s= math.sqrt(p * (p-a) * (p-b) * (p-c))
- return s
- while True:
- choice = input("Круг(к), прямоугольник(п) или треугольник(т): ")
- if choice == 'к':
- r = float(input("Радиус: "))
- print("Площадь круга: %.2f" % circle(r))
- elif choice == 'п':
- a = float(input("Длина: "))
- b = float(input("Ширина: "))
- print("Площадь прямоугольника: %.2f" % rectangle(a,b))
- elif choice == 'т':
- a = float(input("Первая сторона: "))
- b = float(input("Вторая сторона: "))
- c = float(input("Третья сторона: "))
- print("Площадь треугольника: %.2f" % triangle(a,b,c))
- else: print("введите фигуру правильно!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement