-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinMax.py
More file actions
63 lines (54 loc) · 1.62 KB
/
MinMax.py
File metadata and controls
63 lines (54 loc) · 1.62 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
61
62
63
def main():
global iterations
iterations = getIterations()
global numList
numList=getNumList()
getMin(numList)
getMax(numList)
sortList(numList)
programContinues()
def getIterations():
return int(input("How many numbers would you like to compare?"))
def getNumList():
numList=[]
for iteration in range(0,iterations):
num=int(input("Enter your number:"))
numList.append(num)
print("Your list of numbers are:")
print(numList)
return numList
def getMin(numCompare):
numMin = numCompare[0]
for iteration in range(0,iterations):
if numMin>numCompare[iteration]:
numMin=numCompare[iteration]
print("Your min number is:")
print(numMin)
def getMax(numCompare):
numMax = numCompare[0]
for iteration in range(0, iterations):
if numMax < numCompare[iteration]:
numMax = numCompare[iteration]
print("Your max number is:")
print(numMax)
def sortList(numbList):
sortedList=[]
while numbList:
minimum = numbList[0]
for sort in numbList:
if sort < minimum:
minimum = sort
sortedList.append(minimum)
numbList.remove(minimum)
print ("Your numbers sorted are:")
print (sortedList)
def programContinues():
continueProgram = True
while(continueProgram==True):
wantToContinue=str(input("-----Press Q if you want to quit, all other input continues:"))
wantToContinue = wantToContinue.strip()
if wantToContinue == "Q" or wantToContinue == "q":
continueProgram = False
else:
main()
main()