Floating point numbers in the average question


I got the correct answer for the question, but I have a question about the following line:
avg = grades_sum(grades)/float(len(grades))

Why can't we just use (len(grades)), especially when the number of elements is a whole number? Is there a rule that you can't perform operations between a decimal value (the sum of grades) and whole numbers?


An integer divided by an integer yields an integer. When either or both operands is a float, the quotient is a float.

    2 / 10
    # == 0
    2.0 / 10
    # == 0.2
    2 / 10.0
    # == 0.2