In: Computer Science
Write a Python 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
REMEMBER - to put your name on the lab in comments and put comments in your program for what the program is doing.
Don't forget the comments.
# function to determine grade
def determine_grade(score):
if score >= 90:
return 'A'
elif score >= 80:
return 'B'
elif score >= 70:
return 'C'
elif score >= 60:
return 'D'
else:
return 'F'
def calc_average(g1, g2, g3, g4, g5):
# calculate the average of grades and return result
return (g1 + g2 + g3 + g4 + g5) / 5.0
def main():
# get score
score1 = int(input("Enter a score: "))
# determine and print grade
print("Letter grade is " + determine_grade(score1))
# get score
score2 = int(input("Enter a score: "))
# determine and print grade
print("Letter grade is " + determine_grade(score2))
# get score
score3 = int(input("Enter a score: "))
# determine and print grade
print("Letter grade is " + determine_grade(score3))
# get score
score4 = int(input("Enter a score: "))
# determine and print grade
print("Letter grade is " + determine_grade(score4))
# get score
score5 = int(input("Enter a score: "))
# determine and print grade
print("Letter grade is " + determine_grade(score5))
# find average of scores
avg = calc_average(score1, score2, score3, score4, score5)
# print average
print("Average score is " + str(avg))
print("Average grade is " + determine_grade(avg)) # find grade of average and print
if __name__ == '__main__':
main() # call main function