5/9 - Exam stats


#1
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))

def grades_average(grades_input):
    input = len(grades)
    a = float(grades_sum(grades)/input)
    print(a)

grades_average(grades)

whats wrong with this code?I executed this in pycharm and i am getting the desired o/p but the codecademy console says it has some error


#2

i find it impressive you can compile an interpreted language.

if you actually include the error message or the exercise url (preferable) both, you are making things a lot easier for the helping side, getting a better reply in return. This is the error message i get:

grades should contain [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]!

it looks like your list doesn’t contain the right values, a pretty self explaining error?

seems you missed the last bullet point of the instructions:

Returns the average.

you should recognize return as a keyword.

also, your function has a parameter (grades_input) but you are not using it, why?


#3

even with the same values i get the desired output,i have tried multiple i/p


#4

if you don’t bother to read my reply and improve upon what i suggest, its frustrating for me

The reply you just gave me is something i can’t do much with. Maybe i am not the right person to help you


#5

hey i just fixed it got the output.Thanks

And sorry for the incomplete information,next time for any doubt would provide you with adequate information!


#6

here is a good topic:

Quick Tips for Writing Good Posts

which explains the information required and why we require it. In the end, this only helps yourself. Given you get a better response.


#7

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