Question
Analyze the code and fix the errors? Write a program that asks the user to enter five test scores. The program should display a letter
Analyze the code and fix the errors?
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following functions in the program:
calc_average - this function should accept five test scores as arguments and return the average of the scores.
determine_grade - this function should accept a test score 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
Here is what I have (I copied and pasted it so I don't know if it will affect the indentation):
def main():
grade1=int(input('Enter your first grade: '))
grade2=int(input('Enter your second grade: '))
grade3=int(input('Enter your third grade: '))
grade4=int(input('Enter your fourth grade: '))
grade5=int(input('Enter your fith grade: '))
average=calc_average(grade1,grade2,grade3,grade4,grade5)
print('Your average score is ', average)
determine_grade(average)
def calc_average(grade1,grade2,grade3,grade4,grade5):
average_score = (grade1+grade2+grade3+grade4+grade5)/5
return average_score
def determine_grade(score):
if score < 60:
print('your grade is an F')
elif score >=60 and <=69:
print('your grade is a D')
elif score >=70 and <=79:
print('your score is a C')
elif score >=80 and <=89:
print('your score is a B')
elif score >=90 and <=100:
print('your grade is an A')
else:
print('Error: you have not entered a number between 0 and 100.')
return score
main()
Step by Step Solution
3.44 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
Solution There are a few errors in your code Ill point them out and provide you wi...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started