Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

waterlubber

Help me! Codecademy error with this code: def getAverage(x): h = sum(x['homework']) * .1 q = sum(x['quizzes']) * .3 t = sum(x['tests']) * .6 return h + q + t (Just weight and see)

  • one year ago
  • one year ago

  • This Question is Closed
  1. tyteen4a03
    Best Response
    You've already chosen the best response.
    Medals 0

    What is inside x['homework'/'quizzes'/'tests']?

    • one year ago
  2. rsmith6559
    Best Response
    You've already chosen the best response.
    Medals 0

    And what is that sum function, it could be causing problems.

    • one year ago
  3. irfans
    Best Response
    You've already chosen the best response.
    Medals 0

    Is this a fragment of code or whole code. You have a function but where is rest of the code?

    • one year ago
  4. tyteen4a03
    Best Response
    You've already chosen the best response.
    Medals 0

    The sum() function is a built-in function that takes the sum of an iterable (list, iterator, set, generator, etc)

    • one year ago
  5. Shadowys
    Best Response
    You've already chosen the best response.
    Medals 0

    you forgot to put the dot after x, e.g.x.['homework'](the dot means 'the method/element of something'.

    • one year ago
  6. peterdb
    Best Response
    You've already chosen the best response.
    Medals 0

    If you copied and pasted the code then the "t = sum" line looks misaligned from the lines above it.

    • one year ago
  7. tyteen4a03
    Best Response
    You've already chosen the best response.
    Medals 0

    @Shadowys Incorrect. the dot syntax is used to reference an object's methods, not used to access array elements. The syntax of this function is correct.

    • one year ago
  8. Shadowys
    Best Response
    You've already chosen the best response.
    Medals 0

    ah. I got it. sorry about that.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.