Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calc_area():
- _input_ = input('Enter the shape you want to calculate area of (Triangle/Square/Rectangle/Rhombus/Trapezoid): ')
- area = 0
- if _input_ == 'Triangle':
- base = int(input('Enter the value of base: '))
- height = int(input('Enter the value of height: '))
- area = area + (0.5 * base * height)
- elif _input_ == 'Square':
- side = int(input('Enter the value of side: '))
- area = area + (side ** 2)
- elif _input_ == 'Rectangle':
- length = int(input('Enter the value of length: '))
- width = int(input('Enter the value of length: '))
- area = area + (length * width)
- elif _input_ == 'Rhombus':
- diagonal_1 = int(input('Enter Rhombus First Diagonal: '))
- diagonal_2 = int(input('Enter Rhombus Second Diagonal: '))
- area = (diagonal_1 * diagonal_2) / 2
- elif _input_ == 'Trapezoid':
- height = int(input('Height of trapezoid: '))
- base_1 = int(input('Enter Trapezoid first base: '))
- base_2 = int(input('Enter Trapezoid second base: '))
- area = ((base_1 + base_2) / 2) * height
- else:
- print('Enter a valid shape')
- print(area)
- calc_area()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement