Computing the average: get my result is rounded


#1

Read a few messages about this exercice but i still dont get why my result is rounded…
I get 80.0 instead of the 80.42etc.

Any help ? =)

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

def grades_sum(scores):
    somme = 0.0
    for score in scores:
        somme += score
    return somme

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

#2

grades_sum(grades) // float(len(grades))

use / operator not //

The instruction doesn’t want floor division


#3

Tiredness… Thanks @rcodeman !


#4

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