The Studen becomes teacher. Exercise 4


#1



In the exercise 4, I need help, I have made the exercise of a logical form but in my opinion not properly done as requested. Exercise should show the keys in an orderly manner. I expect an answer serve as an aid.


{'tareas': [90.0, 97.0, 75.0, 92.0], 'nombre': 'Candela', 'examenes': [75.0, 90.0], 'pruebas': [88.0, 40.0, 94.0]}
{'tareas': [100.0, 92.0, 98.0, 100.0], 'nombre': 'Milagros', 'examenes': [89.0, 97.0], 'pruebas': [82.0, 83.0, 91.0]}
{'tareas': [0.0, 87.0, 75.0, 22.0], 'nombre': 'Ramiro', 'examenes': [100.0, 100.0], 'pruebas': [0.0, 75.0, 78.0]}
This shows the window result

for k in alumnos:
    print k
This is my code.


#2

At the building stage, it is beneficial to have lots of structure and ample white space. It contributes to both readability and debugging.

The above suggests there is a structure that either houses or references student objects. Your code above is missing this structure.

To illustrate...

candela = {
    'nombre': 'Candela',
    'tareas': [90.0, 97.0, 75.0, 92.0],
    'examenes': [75.0, 90.0],
    'pruebas': [88.0, 40.0, 94.0]
}
milagros = {
    'nombre': 'Milagros',
    'tareas': [100.0, 92.0, 98.0, 100.0],
    'examenes': [89.0, 97.0],
    'pruebas': [82.0, 83.0, 91.0]
}
ramiro = {
    'nombre': 'Ramiro',
    'tareas': [0.0, 87.0, 75.0, 22.0],
    'examenes': [100.0, 100.0],
    'pruebas': [0.0, 75.0, 78.0]
}

def list_alumnus (alumnus):
    print alumnus['nombre']
    for key in alumnus:
        if key != 'nombre':
            print key, alumnus[key]

Then,

alumnos = [ candela, milagros, ramiro ]

list_alumnus(alumnos[0])
Candela
tareas [90.0, 97.0, 75.0, 92.0]
examenes [75.0, 90.0]
pruebas [88.0, 40.0, 94.0]