Getting a little bit creative


#1

script.py

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]
}

students = [lloyd, alice, tyler]
print
print lloyd[‘name’]
print ‘Homework’, lloyd[‘homework’]
print ‘Quizzes’, lloyd[‘quizzes’]
print ‘Tests’, lloyd[‘tests’]
print
print alice[‘name’]
print ‘Homework’, alice[‘homework’]
print ‘Quizzes’, alice[‘quizzes’]
print ‘Tests’, alice[‘tests’]
print
print tyler[‘name’]
print ‘Homework’, tyler[‘homework’]
print ‘Quizzes’, tyler[‘quizzes’]
print ‘Tests’, tyler[‘tests’]

Output

Lloyd
Homework [90.0, 97.0, 75.0, 92.0]
Quizzes [88.0, 40.0, 94.0]
Tests [75.0, 90.0]

Alice
Homework [100.0, 92.0, 98.0, 100.0]
Quizzes [82.0, 83.0, 91.0]
Tests [89.0, 97.0]

Tyler
Homework [0.0, 87.0, 75.0, 22.0]
Quizzes [0.0, 75.0, 78.0]
Tests [100.0, 100.0]

I’m posting this because i’m starting to get a little bit creative and I felt proud of myself.
Also, would there be any way to simplify my print functions?


#2

By using a loop to iterate over your students list and bring .format() into play.