Lesson 9 how everybody doing


My code is below . Can anyone tell the difference between printing the below two ways as shown below
First way I get error FLOAT is not callable
Second works fine

for student in students:
average = float(get_class_average(students)) ### with or wothout float throws the same error Float not callable ?
print average
grade = get_letter_grade(average)
print grade

print get_class_average(students)
print get_letter_grade(get_class_average(students))



Your question is a little hard to understand. Please post a screenshot of your screen at the time of the error, so we can better help you fix your problem.


Thanks for the kind concern

My question was , why do I get error when i store the output of function get_class_average(students) in average variable and then print average
Error: Float not callable
I have commented these lines as of now (please see last few lines)

Whearas Calling directly the method print get_class_average(students) works fine
My entire code is below
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))
return float(total) / len(numbers)
students = [lloyd , alice, tyler]
for student in students:
def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
sum = homework*0.1 + quizzes*0.3 + tests*0.6
return sum
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" 
    return "F"

score = get_average(lloyd)
grade = get_letter_grade(score)
print grade
students = [lloyd , alice, tyler]

print students

def get_class_average(students):
results = []
for student in students:
return average(results)

for student in students:
#average = float(get_class_average(students))
#print average
#grade = get_letter_grade(average)
#print grade
print get_class_average(students)
print get_letter_grade(get_class_average(students))


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