daily pastebin goal
9%
SHARE
TWEET

Figures Area

Sim0o0na May 3rd, 2018 132 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 1. Read figure type
  2. import math
  3.  
  4. figure_type = input()
  5.  
  6. # 2. Check if:
  7. #   a: square -> read "a" // calc
  8. #   b: rectangle -> read width and length // calc
  9. #   c: circle -> read radius
  10. #   d: triangle -> read "a" and ha
  11.  
  12. a = float(input())
  13. area = 0
  14.  
  15. if figure_type == "square":
  16.     area = a * a
  17. elif figure_type == "rectangle":
  18.     b = float(input())
  19.     area = a * b
  20. elif figure_type == "circle":
  21.     # pi * r * r
  22.     area = math.pi * math.pow(a, 2)
  23. elif figure_type == "triangle":
  24.     height = float(input())
  25.     area = a * height / 2
  26.  
  27. print("%.2f" % area)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top