You are viewing our Forum Archives. To view or take place in current topics click here.
[Pyfon] [Hur dur] Codecademy Retardedness
Posted:

[Pyfon] [Hur dur] Codecademy RetardednessPosted:

Churro-
  • TTG Addict
Status: Offline
Joined: Apr 21, 201212Year Member
Posts: 2,401
Reputation Power: 166
Status: Offline
Joined: Apr 21, 201212Year Member
Posts: 2,401
Reputation Power: 166
Anybody have a clue why this is not working properly?


lloyd = {
    "name": "Lloyd",
    "homework": [90.0, 97.0, 75.0, 92.0],
    "quizzes": [88.0, 40.0, 94.0],
    "tests": [75.0, 90.0]
}
alice = {
    "name": "Alice",
    "homework": [100.0, 92.0, 98.0, 100.0],
    "quizzes": [82.0, 83.0, 91.0],
    "tests": [89.0, 97.0]
}
tyler = {
    "name": "Tyler",
    "homework": [0.0, 87.0, 75.0, 22.0],
    "quizzes": [0.0, 75.0, 78.0],
    "tests": [100.0, 100.0]
}

def average(numbers):
    total = sum(numbers)
    total = float(total) / len(numbers)
    return total

def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    student_average = (homework * .1) + (quizzes * .3) + (tests * .6)
    return student_average
   
def get_letter_grade(score):
    if score >= 90:
        return "A"
    elif score >= 80:
        return "B"
    elif score >= 70:
        return "C"
    elif score >= 60:
        return "D"
    else:
        return "F"

get_letter_grade(get_average(lloyd))

def get_class_average(students):
    results = []
    for student in students:
        results.append(get_average(student))
        return average(results)



What codecademy returns
[ Register or Signin to view external links. ]



EDIT- mfw that is the whole "batch"


Last edited by Churro- ; edited 1 time in total
#2. Posted:
Boar
  • TTG Addict
Status: Offline
Joined: Jul 25, 201014Year Member
Posts: 2,132
Reputation Power: 308
Status: Offline
Joined: Jul 25, 201014Year Member
Posts: 2,132
Reputation Power: 308
Well for starters the whole batch of code would be very useful here.

Have you checked your main function for calculating and also the variables for the scores, one digit out would make or break it.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.