Sichanov

area_of_figures

May 26th, 2021
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. import math
  2.  
  3. figure_type = input()
  4.  
  5. area = 0
  6.  
  7. if figure_type == "square":
  8.     side = float(input())
  9.     area = side * side
  10. elif figure_type == "rectangle":
  11.     a = float(input())
  12.     b = float(input())
  13.     area = a * b
  14. elif figure_type == "circle":
  15.     r = float(input())
  16.     area = math.pi * r ** 2
  17. elif figure_type == "triangle":
  18.     c = float(input())
  19.     h = float(input())
  20.     area = (c * h) / 2
  21.  
  22. print(f"{area:.3f}")
Advertisement
Add Comment
Please, Sign In to add comment