Answer to Question #190204 in Python for Angelie Suarez

Question #190204

2. Create a function that has 5 parameters. This function will calculate the average grade of 5 subjects.

The 5 grades on each subject should be 1 line of user input.


sample output:

Enter 5 Grades: 70 72 73 74 60

Your average grade is 69.8 and you are failed.


1
Expert's answer
2021-05-07T00:03:43-0400
def average_grade(g1, g2, g3, g4, g5):


	average = (g1 + g2 + g3 + g4 + g5) / 5
	return average


while True:
	try:
		tests = list(map(int, input('Enter 5 Grades: ').split()))
	except:
		print('incorrect input')
		continue
	if len(tests) != 5:
		print('enter five grades')
		continue
	if average_grade(*tests) < 70:
		s = 'failed'
	else:
		s = 'succeeded'
	print('Your average grade is {} and you are {}.'.format(average_grade(*tests), s))
	break

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS