Respuesta :
Answer:
def gradeAverage():
grades = []
i = 0
while i < 5:
a = int(input('enter score ' + str(i + 1) + ': '))
grades.append(a)
i = i+1
#print(grades)
average = sum(grades)/len(grades)
#print(average)
return average
def lettergrade(a):
letter = 'A'
if a < 60:
letter = 'F'
elif 59 < a < 63:
letter = 'D-'
elif 62 < a < 67:
letter = 'D'
elif 66 < a < 70:
letter = 'D+'
elif 69 < a < 73:
letter = 'C-'
elif 72 < a < 77:
letter = 'C'
elif 76 < a < 80:
letter = 'C+'
elif 79 < a < 83:
letter = 'B-'
elif 82 < a < 87:
letter = 'B'
elif 86 < a < 90:
letter = 'B+'
elif 89 < a < 94:
letter = 'A-'
elif 93 < a < 101:
letter = 'A'
return letter
numOfStudents = int(input('How many students: '))
names = []
aver = []
grade =[]
while numOfStudents > 0:
studentName = input('Enter students name: ')
names.append(studentName)
a = gradeAverage()
aver.append(a)
grade.append(lettergrade(a))
numOfStudents = numOfStudents - 1
for name in names:
for score in aver:
for letter in grade:
if names.index(name) == aver.index(score) == grade.index(letter):
print('%s : Average = %d Letter Grade: %s \n' %(name, score, letter))
break
Explanation:
The programming language used is python.
Two functions were created, the first function gradeAverage() was used to calculate the average values of the scores.
The second function lettergrade(a) was used to get the letter grade i.e(A, A-, C, D, e.t.c.) and it takes its argument from the average.
The main block of code asks for how many students are there and prompts the user to input their names and scores for all the students.
It takes that data calculates the average and the letter grade and prints out the names of the students, their average and their letter grade.