-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmenu-driven.py
More file actions
60 lines (51 loc) · 1.57 KB
/
menu-driven.py
File metadata and controls
60 lines (51 loc) · 1.57 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#Sureyya Betul Akis
#creates a menu-driven program that allows a user to enter five numbers (integers)
def main():
firstInput = 0
secondInput = 0
thirdInput = 0
fourtInput = 0
fifthInput = 0
while True:
firstInput = AcceptUsersInput()
secondInput = AcceptUsersInput()
thirdInput = AcceptUsersInput()
fourtInput = AcceptUsersInput()
fifthInput = AcceptUsersInput()
userList = [firstInput, secondInput, thirdInput, fourtInput, fifthInput]
menu_driven()
answer = int(input(" Enter your answer: "))
if answer == 1:
theSmallest(userList)
elif answer == 2:
theLargest(userList)
elif answer == 3:
theSumof5(userList)
elif answer == 4:
theAverage(userList)
else:
break
def AcceptUsersInput():
Input = int(input("Enter a numbers between 25 to 225 (integers):"))
while(not(Input >= 25 and Input <= 225)):
print("Error, please try again!")
Input = int(input("Enter a numbers between 25 to 225 (integers):"))
return Input
def menu_driven():
print(" _______\n")
print(" MENU")
print(" _______\n")
print(" 1. Find the Smallest number")
print(" 2. Find the Largest number")
print(" 3. Find the Sum of numbers")
print(" 4. Find the Average of numbers")
print(" 5. End\n")
def theSmallest(userList):
print(min(userList))
def theLargest(userList):
print(max(userList))
def theSumof5(userList):
print(sum(userList))
def theAverage(userList):
print(float(sum(userList)) / max(len(userList),1))
main()