-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program_5-28.py
46 lines (40 loc) · 1.51 KB
/
Program_5-28.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import circle
import rectangle
AREA_CIRCLE_CHOICE = 1
CIRCUMFERENCE_CHOICE = 2
AREA_RECTANGLE_CHOICE = 3
PERIMETER_RECTANGLE_CHOICE = 4
QUIT_CHOICE = 5
def main():
choice = 0
while choice != QUIT_CHOICE:
display_menu()
choice = int(input('Enter your choice: '))
if choice == AREA_CIRCLE_CHOICE:
radius = float(input("Enter the circle's radius: "))
print('The area is', circle.area(radius))
elif choice == CIRCUMFERENCE_CHOICE:
radius = float(input("Enter the circle's radius: "))
print('the circumference is', \
circle.circumference(radius))
elif choice == AREA_RECTANGLE_CHOICE:
width = float(input("Enter the rectangle's width: "))
length = float(input("Enter the rectangles's length: "))
print('The area is', rectangle. area(width, length))
elif choice == PERIMETER_RECTANGLE_CHOICE:
width = float(input("Enter the rectangle's width: "))
length = float(input("Enter the rectangle's length: "))
print('The perimter is', \
rectangle.perimeter(width, length))
elif choice == QUIT_CHOICE:
print('Exiting the program...')
else:
print('Error: invalid selection.')
def display_menu():
print(' menu')
print('1) Area of a circle')
print('2) Circumference of a circle')
print('3) Area of a rectangle')
print('4) Perimeter of a rectangle')
print('5) Quit')
main()