To Codecademy (Possible Problem)


#1

Hi Codecademy, I appreciate all your help. Thank you.

Anyways, my code for Student Becomes the Teacher
- Sending a Letter is correct. It prints the letter grade for Lloyd as a 80.55% which is a B. But, the interpreter gives me a error of

Oops, try again. get_letter_grade(100) returned 'B' instead of 'A' as expected.

MY CODE:
lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

Add your function below!

def average(numbers):
total = sum(numbers)
total = float(total)
result = total / len(numbers)
return result

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return 0.1 * homework + 0.3 * quizzes + 0.6 * tests

def get_letter_grade(score):
score = get_average(student)
if score >= 90:
return "A"
elif 80 >= score < 90:
return "B"
elif 70 >= score < 80:
return "C"
elif 60 >= score < 70:
return "D"
else:
return "F"
get_letter_grade(get_average(lloyd))
print (get_letter_grade(get_average(lloyd)))


#2

@alankwtam26,
With your

score = get_average(student)

you are re-assigning the parameter ( which is receiving the argument at the call )

the FUNCTION talk

def myFunc( param1, param2):
    # Begin of =myFunc= FUNCTION-BODY
    # this =myFunc= function- has 2 PARAMETERS param1 and param2
    # param1 and param2 PARAMETERS are used 
    # as -local- VARIABLES throughout the =myFunc= FUNCTION-BODY
    print( param1 + " and " + param2 )
    #End of =myFunc= FUNCTION-BODY

If you want to call/execute the myFunc function
you will have to add a pair of parentheses to myFunc
like
myFunc()
As the myFunc function was defined
as having 2 parameters
you have to provide 2 arguments
in our case 2 string VALUES "Alena" and "Lauren"
like
myFunc("Alena","Lauren")

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++ function with 1 parameter using return-statement

def myFunction( param1 ):
    # //Begin of =myFunction= FUNCTION-BODY
    # //=myFunction= function has 1 PARAMETER param1
    # //this param1 PARAMETER is used as a -local- VARIABLE
    # //throughout the =myFunction= FUNCTION-BODY
    return param1;
    # //End of FUNCTION-BODY

You have defined a myFunction function
which takes 1 parameter param1
this param1 parameter is used
as a variable throughout the =myFunction= FUNCTION-BODY.

If you want to call/execute this myFunction function
and this myFunction function was defined
as having 1 parameter param1
you will have to provide 1 argument
in our case a "number VALUE" 4
myFunction( 4 )

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**

============================================

As you are using the return-statement in your myFunction function
you will only get a return-value no-display.
You can however capture this return-value in a variable
and then use the print-method to do a display.

theResult = myFunction( 4 )
print theResult

OR directly

print myFunction( 4 )

#3

When it say's get_letter_grade(100) that's CodeAcademy passing in 100 as an argument to test your code and it's saying it gets 'B' back when it passes in 100 instead of what it expects, which is 'A'. At least that's how I understand it. So there's an error somewhere. If what Leonhard said helped you find the error, awesome! :slight_smile: His explanation just confused me so on the off change you still can't find your error, if you copy and past this:

```python

PASTE YOUR CODE HERE

```

so your code will format properly, I'll check it out real quick!


#4

lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

students = [lloyd, alice, tyler]

Add your function below!

for student in students:
print()

def average(numbers):
total = sum(numbers)
total = float(total)
result = total / len(numbers)
return result

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return 0.1 * homework + 0.3 * quizzes + 0.6 * tests

def get_letter_grade(score):
score = get_average(student)
if score >= 90:
return "A"
elif 80 >= score < 90:
return "B"
elif 70 >= score < 80:
return "C"
elif 60 >= score < 70:
return "D"
else:
return "F"
get_letter_grade(get_average(lloyd))
print (get_letter_grade(get_average(lloyd)))