Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import math
  2.  
  3. def circle(r):
  4. s = math.pi * r**2
  5. return s
  6.  
  7. def rectangle(a, b):
  8. s= a*b
  9. return s
  10.  
  11. def triangle(a, b, c):
  12. p = (a+b+c)/2
  13. s= math.sqrt(p * (p-a) * (p-b) * (p-c))
  14. return s
  15.  
  16. while True:
  17. choice = input("Круг(к), прямоугольник(п) или треугольник(т): ")
  18. if choice == 'к':
  19. r = float(input("Радиус: "))
  20. print("Площадь круга: %.2f" % circle(r))
  21. elif choice == 'п':
  22. a = float(input("Длина: "))
  23. b = float(input("Ширина: "))
  24. print("Площадь прямоугольника: %.2f" % rectangle(a,b))
  25. elif choice == 'т':
  26. a = float(input("Первая сторона: "))
  27. b = float(input("Вторая сторона: "))
  28. c = float(input("Третья сторона: "))
  29. print("Площадь треугольника: %.2f" % triangle(a,b,c))
  30. else: print("введите фигуру правильно!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement