Lyubohd

07. Area of Figures

Apr 25th, 2020
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import math
  2. figure = input()
  3. area = 0
  4.  
  5. if figure == "square":
  6.     side = float(input())
  7.     area = pow(side, 2)  # (side * side), (side ** 2)
  8. elif figure == "rectangle":
  9.     sideA = float(input())
  10.     sideB = float(input())
  11.     area = sideA * sideB
  12. elif figure == "circle":
  13.     radius = float(input())
  14.     area = math.pi * radius ** 2
  15. elif figure == "triangle":
  16.     side = float(input())
  17.     height = float(input())
  18.     area = side * height / 2
  19. print(f"{area:.3f}")
Advertisement
Add Comment
Please, Sign In to add comment