fork(1) download
  1. # Даны три списка student_ids, student_names, student_grades, содержащие информацию о студентах.
  2.  
  3. # Дополните приведенный код, используя генератор, так чтобы получить список result, содержащий вложенные словари
  4. # в соответствии с образцом: [{'S001': {'Camila Rodriguez': 86}}, {'S002': {'Juan Cruz': 98}},...].
  5.  
  6. student_ids = ['S001', 'S002', 'S003', 'S004', 'S005', 'S006', 'S007', 'S008', 'S009', 'S010', 'S011', 'S012', 'S013']
  7.  
  8. student_names = ['Camila Rodriguez', 'Juan Cruz', 'Dan Richards', 'Sam Boyle', 'Batista Cesare', 'Francesco Totti', 'Khalid Hussain', 'Ethan Hawke', 'David Bowman', 'James Milner', 'Michael Owen', 'Gary Oldman', 'Tom Hardy']
  9.  
  10. student_grades = [86, 98, 89, 92, 45, 67, 89, 90, 100, 98, 10, 96, 93]
  11.  
  12. def information_about_students(list_ids, list_names, list_grades):
  13. return [{list_ids[i]: {list_names[j]: list_grades[j] for j in range(i, i + 1)} for i in range(i, i + 1)} for i in range(len(list_ids))]
  14.  
  15. result = information_about_students(student_ids, student_names, student_grades)
  16. print(result)
Success #stdin #stdout 0.03s 63596KB
stdin
Standard input is empty
stdout
[{'S001': {'Camila Rodriguez': 86}}, {'S002': {'Juan Cruz': 98}}, {'S003': {'Dan Richards': 89}}, {'S004': {'Sam Boyle': 92}}, {'S005': {'Batista Cesare': 45}}, {'S006': {'Francesco Totti': 67}}, {'S007': {'Khalid Hussain': 89}}, {'S008': {'Ethan Hawke': 90}}, {'S009': {'David Bowman': 100}}, {'S010': {'James Milner': 98}}, {'S011': {'Michael Owen': 10}}, {'S012': {'Gary Oldman': 96}}, {'S013': {'Tom Hardy': 93}}]