desislava_topuzakova

06. Area of Figures

Apr 10th, 2021
597
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 1. вид на фигурата (текст) -> конзолата
  2. # 2. проверка за вид на фигура
  3.     # square -> страна -> лице = страна * страна -> print -> OK
  4.     # rectangle -> дължина и ширина -> лице = дължина * ширина -> OK
  5.     # circle -> радиус -> лице = пи * радиус * радиус -> OK
  6.     # triangle -> страна и височина -> лице = страна * височина / 2
  7. import math
  8. figure_type = input()
  9.  
  10. if figure_type == "square":
  11.     a = float(input())
  12.     area = a ** 2
  13.     print(f"{area:.3f}")
  14. elif figure_type == "rectangle":
  15.     length = float(input())
  16.     width = float(input())
  17.     area = length * width
  18.     print(f"{area:.3f}")
  19. elif figure_type == "circle":
  20.     radius = float(input())
  21.     area = math.pi * math.pow(radius, 2)
  22.     print(f"{area:.3f}")
  23. elif figure_type == "triangle":
  24.     side = float(input())
  25.     h = float(input())
  26.     area = side * h / 2
  27.     print(f"{area:.3f}")
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×