Advertisement
desislava_topuzakova

06. Area of Figures

Oct 10th, 2020
1,387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. #1. вид на фигура: квадрат (square), правоъгълник (rectangle), кръг (circle) и триъгълник (triangle)
  2. import math
  3. type = input()
  4.  
  5. if type == "square":
  6.     square_side = float(input())
  7.     square_area = math.pow(square_side, 2)
  8.     print(f"{square_area:.3f}")
  9. elif type == "rectangle":
  10.     width = float(input())
  11.     length = float(input())
  12.     rectangle_area = width * length
  13.     print(f"{rectangle_area:.3f}")
  14. elif type == "circle":
  15.     r = float(input())
  16.     circle_area = math.pi * math.pow(r, 2)
  17.     print(f"{circle_area:.3f}")
  18. elif type == "triangle":
  19.     triangle_side = float(input())
  20.     h = float(input())
  21.     triangle_area = triangle_side * h / 2
  22.     print(f"{triangle_area:.3f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement