Advertisement
Dido09

Area Calculator

Dec 14th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. def calc_area():
  2. _input_ = input('Enter the shape you want to calculate area of (Triangle/Square/Rectangle/Rhombus/Trapezoid): ')
  3. area = 0
  4. if _input_ == 'Triangle':
  5. base = int(input('Enter the value of base: '))
  6. height = int(input('Enter the value of height: '))
  7. area = area + (0.5 * base * height)
  8. elif _input_ == 'Square':
  9. side = int(input('Enter the value of side: '))
  10. area = area + (side ** 2)
  11. elif _input_ == 'Rectangle':
  12. length = int(input('Enter the value of length: '))
  13. width = int(input('Enter the value of length: '))
  14. area = area + (length * width)
  15. elif _input_ == 'Rhombus':
  16. diagonal_1 = int(input('Enter Rhombus First Diagonal: '))
  17. diagonal_2 = int(input('Enter Rhombus Second Diagonal: '))
  18. area = (diagonal_1 * diagonal_2) / 2
  19. elif _input_ == 'Trapezoid':
  20. height = int(input('Height of trapezoid: '))
  21. base_1 = int(input('Enter Trapezoid first base: '))
  22. base_2 = int(input('Enter Trapezoid second base: '))
  23. area = ((base_1 + base_2) / 2) * height
  24. else:
  25. print('Enter a valid shape')
  26. print(area)
  27.  
  28. calc_area()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement