using python 3 (Assign grades) Write a program that reads a list of scores and t
ID: 3776602 • Letter: U
Question
using python 3 (Assign grades) Write a program that reads a list of scores and then assigns grades based on the following scheme: The grade is A if score is best – 10. The grade is B if score is best – 20. The grade is C if score is best – 30. The grade is D if score is best – 40. The grade is F otherwise. Here is a sample run: Enter scores: 40 55 70 58 Student 0 score is 40 and grade is C Student 1 score is 55 and grade is B Student 2 score is 70 and grade is A Student 3 score is 58 and grade is B
Explanation / Answer
Assigning Grades Program:
print (" Assinging Grades ")
def Best(list):
if len(list) == 1:
return list[0]
else:
a = Best(list[1:])
return a if a > list[0] else list[0]
def main():
print(" Enter the scores separated by space:")
list = input().split()
print(" ")
print(" Score"," Grade")
print(" ======"," ======")
for i in range(len(list)):
b = int(Best(list))-int(list[i])
if (b<=10):
print (" ",list[i]," A")
elif (b<=20):
print (" ",list[i]," B")
elif (b<=30):
print (" ",list[i]," C")
elif (b<=40):
print (" ",list[i]," D")
else:
print (" ",list[i]," F")
main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.