finderabc

06. Area of Figures

Sep 23rd, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #1. прочитаме фигура
  2. #2. квадрат (square), правоъгълник (rectangle), кръг (circle) и триъгълник (triangle).
  3. import math
  4. type = input()
  5. if type == 'square': # s = a * a
  6.     a = float(input())
  7.     area_square = math.pow(a, 2) # a*a
  8.     print(f"{area_square:.3f}")
  9. elif type == 'rectangle': # s = a * b
  10.     a = float(input())
  11.     b = float(input())
  12.     print(f"{a * b:.3f}")
  13. elif type == 'circle': # s = pi * r * r
  14.     r = float(input())
  15.     area_circle = math.pi * math.pow(r , 2)
  16.     print(f"{area_circle:.3f}")
  17. elif type == 'triangle': # s =  a * h / 2
  18.     a = float(input())
  19.     h = float(input())
  20.     area_triangle = a * h / 2
  21.     print(f"{area_triangle:.3f}")
Add Comment
Please, Sign In to add comment