7.sending a letter


#1



where does my code go wrong? I get the average score for a student. e.g.. Alice is 91.15, later on I set it to my score and give a grade to my score. my formula keeps returning C for all the averages.


>>> get_average(lloyd)
80.55
>>> get_average(tyler)
79.9
>>> get_average(alice)
91.14999999999999
>>> def get_letter_grade(score):
	score=get_average(student)
	if score>=90:
		return "A"
	elif score>=80:
		return "B"
	elif score>=70:
		return "C"
	elif score>=60:
		return "D"
	else:
		return "F"


#2

Hi @objectplayer39020 ,

What is the purpose of having this statement within your get_letter_grade function? ...

score=get_average(student)

#3

rather than writing get_letter_grade(get_average(alice)) this is supposed to do the work in the get_letter_grade formula itself.


#4

The problem is that the statement causes the function to ignore its score parameter, overwriting it with another value based on an external variable, student. The function should be designed to accept a numerical grade, and Codecademy bases its submission correctness test (SCT) on that expectation. That statement should be removed.

The work of calling the get_average function should be done outside the get_letter_grade function.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.