# Where is my error?

#1

I'm getting a error message saying "get_class_average ([alice]) return 83.86 instead of 91.15. when I run her score individually it shows her having a average grade of 91.15? - where is my error?

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": [00.0, 87.0, 75.0, 22.0],
"quizzes": [00.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

def average(numbers):
t = sum(numbers)
x = len(numbers)
v = float(t) / float(x)
return v

def get_average(student):
hom = average(student["homework"])
qzz = average(student["quizzes"])
tes = average(student["tests"])
s_avg = (hom * 0.10) + (qzz * 0.30) + (tes * 0.60)
return s_avg

print"Alice has"
print (get_average(alice))
print
print"Lloyd has"
print (get_average(lloyd))
print
print"Tyler has"
print (get_average(tyler))

if score >= 90:
return "A"
elif score >= 80:
return "B"
elif score >= 70:
return "C"
elif score >= 60:
return "D"
elif score < 60:
return "F"

def get_class_average(everyone):
for values in students:
return class_average

students = [lloyd, alice, tyler]

print
print "The class average is: "
print get_class_average(students)

Part of the Whole
#2

@agzv,
First of all
try to understand the meaning of a `parameter` and an `argument`

### 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

``````def get_class_average(everyone):
# you are using =everone= as PARAMETER
# this =everyone= PARAMETER is used as a =local= VARIABLE
# throughout this FUNCTION-BODY
for values in everyone:
return class_average``````

Now you will be able to call the get_class_average()
function with any argument
as long as it is an list Value
and the used list-Elements are any combination of alice, lloyd or tyler
like

``get_class_average([alice])``

## https://en.wikipedia.org/wiki/Python_(programming_language)

#4

Thank you Leon for the explanation that make more sense to now. however after looking over everything I'm still getting a class average of 83.86 but the system wants 91.15 which alice has.

#5

@agzv
And if you try it by removing all the extra print's
like

``````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": [00.0, 87.0, 75.0, 22.0],
"quizzes": [00.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

def average(numbers):
t = sum(numbers)
x = len(numbers)
v = float(t) / float(x)
return v``````

``````def get_average(student):
hom = average(student["homework"])
qzz = average(student["quizzes"])
tes = average(student["tests"])
s_avg = (hom * 0.10) + (qzz * 0.30) + (tes * 0.60)
return s_avg
'''
print"Alice has"
print (get_average(alice))
print
print"Lloyd has"
print (get_average(lloyd))
print
print"Tyler has"
print (get_average(tyler))
'''``````

``````def get_letter_grade(score):
if score >= 90:
return "A"
elif score >= 80:
return "B"
elif score >= 70:
return "C"
elif score >= 60:
return "D"
elif score < 60:
return "F"

def get_class_average(everyone):
for values in everyone: