formations/algo/poo/cours/snippets/student_procedural.py

24 lines
635 B
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding: utf-8
# procedural version
student1 = dict(name='pierre', birth_date=None)
student2 = dict(name='paul', birth_date=None)
student3 = dict(name='jacques', birth_date=None)
classrooms_registry = dict(pierre='4eme3', paul='4eme2', jacques='4eme5')
students = [student1, student2, student3]
def move_students():
for student in students:
classroom = classrooms_registry[student['name']]
student['classroom'] = classroom
for student in students:
print "The student: {} is assigned to the class {}".format(student['name'], student['classroom'])
if __name__ == "__main__":
move_students()