Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

danmei

  • 3 years ago

Can someone tell me why the output on this is 4 times? Lloyd = { "name":"Lloyd", "homework": [90,97,75,92], "quizzes": [ 88,40,94], "tests": [75,90] } Tyler = { "name":"Tyler", "homework": [0,87,75,22], "quizzes": [0,75,78], "tests": [100,100] } student = ["Lloyd", "Alice", "Tyler"] def average(student): for person in student: ave = float(sum(student["homework"]))/len(student["homework"]) print ave average(Lloyd)

  • This Question is Closed
  1. lh4219
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    The print avg should be directly under the for

  2. danmei
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    thanks, that did it!

  3. MicroBot
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    actually your code is strange...what are you supposed to do? cause like that it gives only the average of the asked student but you have code u dont need at all.

  4. MicroBot
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Lloyd = { "name":"Lloyd", "homework": [90,97,75,92], "quizzes": [ 88,40,94], "tests": [75,90] } Tyler = { "name":"Tyler", "homework": [0,87,75,22], "quizzes": [0,75,78], "tests": [100,100] } Alice={ "name":"Tyler", "homework": [0,87,75,22], "quizzes": [0,75,78], "tests": [100,100] } def average(student): ave = float(sum(student["homework"]))/len(student["homework"]) print ave average(Lloyd) this does the same thing. i set Alice as you didnt have her .

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy