Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1. прочитаме фигура
- #2. квадрат (square), правоъгълник (rectangle), кръг (circle) и триъгълник (triangle).
- import math
- type = input()
- if type == 'square': # s = a * a
- a = float(input())
- area_square = math.pow(a, 2) # a*a
- print(f"{area_square:.3f}")
- elif type == 'rectangle': # s = a * b
- a = float(input())
- b = float(input())
- print(f"{a * b:.3f}")
- elif type == 'circle': # s = pi * r * r
- r = float(input())
- area_circle = math.pi * math.pow(r , 2)
- print(f"{area_circle:.3f}")
- elif type == 'triangle': # s = a * h / 2
- a = float(input())
- h = float(input())
- area_triangle = a * h / 2
- print(f"{area_triangle:.3f}")
Add Comment
Please, Sign In to add comment