Calculating average grades I'm a C# developer looking to learn more about Python and how to think in a more functional programming manner.

I have the following which takes a series of grades and returns the average:

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

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

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

print(grades_average(grades))


What are some better functional programming / pythonic ways of approaching this problem?
In Python, there is a predefined function sum.  This completely negates your need for grades_sum(scores).

def grades_average(grades):
    return sum(grades) / float(len(grades))


Also, you do not need to cast len(grades) to float if you are using Python 3.