Compute the Average Instructions Misleading


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

https://www.codecademy.com/courses/learn-python/lessons/exam-statistics/exercises/computing-the-average?action=lesson_resume

Why does your instructions refer to grades_input? Especially, when what you’re looking for is ‘grade’ as the argument. Too often your instructions are obtuse and misleading.

```python

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

print grades_sum(grades)
#instead of grade_input like the instructions call for. GRRRRR
def grades_average(grades):
average = grades_sum(grades)/float(len(grades))
return average
print grades_average(grades)

<do not remove the three backticks above>

#2

That is meant as a local variable.

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

Are you saying that the above would not be accepted?


Aside

It may be just me, but I prefer to leave counting numbers as what they are, integers. Cast the number that is more likely to be a float, which in this case is the numerator.


#3

Yours worked but mine wasn’t. Sadly I don’t have that code. This can be closed.


#4

It should have been,

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

If we initialize total as a float we don’t need to worry about floats anywhere else.

total = 0.0

or

total = float(0)

Then it’s just this,

def grades_average(grades_input):
    return grades_sum(grades_input) / len(grades_input)

#5

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