In: Computer Science
Python question
Write a program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name.
Write the following functions in the program:
calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student
determine_grade - this function should accept a test score average as an argument and return a letter grade for the score based on the following grading scale:
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F
Program code:
name=input("Enter student name:");
Score=[];
print("Enter 8 Scores:");
for i in range(8):
val=int(input());
Score.append(val);
def calc_average(Score):
sum=0;
for i in range(8):
sum+=Score[i];
return sum/8;
def determine_grade(average):
if(average>=90 and average<=100):
grade='A'
elif(average>=80 and average<90):
grade='B'
elif(average>=70 and average<80):
grade='C'
elif(average>=60 and average<70):
grade='D'
else:
grade='F'
return grade;
average=calc_average(Score);
print("Average of scores is:",average);
print("Total grade is:",determine_grade(average));
Output:
test case-1:
test case-2: