The grades average 5. Compute the Average


#1

https://www.codecademy.com/courses/python-intermediate-en-7mgOa/1/2?curriculum_id=4f89dab3d788890003000096

I need some help please?
the error keeps saying that it appears to be missing.

error:
Oops, try again. grades_average seems to be missing!

console:
100
200
290
330
410
510
595
665
755
820
910
995
1045.5
100
200
290
330
410
510
595
665
755
820
910
995
1045.5
80.4230769231
None

code:

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
    total = 0
    for i in scores:
        total = total + i
        print total
    return total

grades_sum(grades)
   
    
def grade_average(grades):
    added = grades_sum(grades)
    avg = float((added / len(grades)))
    print avg
    
    
    
grade_average(grades)


#2

Error:

Oops, try again. grades_average seems to be missing

Check the function name. It should be the same what the instruction wants.


#3

i see now ops :smile:
i fixed now but when i tested it it gives me this error now

Oops, try again. grades_average([9, 7, 8, 1]) returned None instead of the expected: 6.25

ohh and also every time i run it again to popup the same error it chages the numbers in the error.


#4

print avg

you should return the avg instead of printing it.

now call the grades_average function with print .

print grades_average(grades)


#5

it still doesn’t work

Oops, try again. grades_average([2, 0, 8, 5, 9, 9, 5, 7]) returned 5.0 instead of the expected: 5.625

updated code:

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
    total = 0
    for i in scores:
        total = total + i
        print total
    return total

grades_sum(grades)
   
    
def grades_average(grades):
    added = grades_sum(grades)
    avg = float((added / len(grades)))
    return avg
    
    
    
print grades_average(grades)

#6

avg = float((added / len(grades)))

you just need float for len(grades) not added


#7

i have tried this but it doesn’t work

avg = float(len(grades))

error:

Oops, try again. You did not print the correct average. Double-check your code and make sure you print the average!


#8

you should divide the added by float value of len(grades) then you’ll get the average.


#9

I see now
Yaaaay It worked thanks for your help
:smile:


#10

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