I need to use fuctions in order to get the following output: bash-4.1$ python gr
ID: 3589236 • Letter: I
Question
I need to use fuctions in order to get the following output:
bash-4.1$ python grades.py
Enter a valid grade (-1 to quit): 100
Enter a valid grade (-1 to quit): 0 Enter a valid grade (-1 to quit): -1
At index 0 there is a 100
At index 1 there is a 0
The minimum is 0 The maximum is 100
bash-4.1$ python grades.py
Enter a valid grade (-1 to quit): -10
The grade -10 is invalid
Grades must be between 0 and 100
Enter a valid grade (-1 to quit): 104
The grade 104 is invalid
Grades must be between 0 and 100
Enter a valid grade (-1 to quit): 90
Enter a valid grade (-1 to quit): 85
Enter a valid grade (-1 to quit): 45
Enter a valid grade (-1 to quit): 97
Enter a valid grade (-1 to quit): 79
Enter a valid grade (-1 to quit): 94
Enter a valid grade (-1 to quit): -1
At index 0 there is a 90
At index 1 there is a 85
At index 2 there is a 45
At index 3 there is a 97
At index 4 there is a 79
At index 5 there is a 94
The minimum is 45
The maximum is 97
Explanation / Answer
#n=int(input("Enter a valid grade(-1 to quit):"))
n=0
i=0
a=1
j=0
b=105
fact=1
myList=[]
while(n!=-1):
n=int(input("Enter a valid grade(-1 to quit):"))
if n>=0 and n<=100:
myList.append(n)
if n>a:
a=n
if n<b:
b=n
else:
print("The grade ",n," is invalid")
print("The grade must be btween 0 and 100")
for value in myList:
print("At index ",j," there is a ",value)
j=j+1
print("The Maximum is: " ,a)
print("The Minimum is: " ,b)