Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
danmei
Group Title
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)
 one year ago
 one year ago
danmei Group Title
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)
 one year ago
 one year ago

This Question is Closed

lh4219 Group TitleBest ResponseYou've already chosen the best response.1
The print avg should be directly under the for
 one year ago

danmei Group TitleBest ResponseYou've already chosen the best response.1
thanks, that did it!
 one year ago

MicroBot Group TitleBest ResponseYou've already chosen the best response.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.
 one year ago

MicroBot Group TitleBest ResponseYou've already chosen the best response.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 .
 one year ago
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
 Engagement 19 Mad Hatter
 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.