Solution: Class Grades
This program stores a list of students with their scores and then prints each student’s name and score.
studentsis a list containing dictionaries.Each dictionary represents one student with two pieces of information:
"name"→ the student’s name"score"→ their test score
The
forloop goes through each student dictionary one by one.Inside the loop:
student['name']gets the student’s name.student['score']gets their score.
The
print()statement displays both pieces of data in one sentence.
Solution: Class Grades
This program stores a list of students with their scores and then prints each student’s name and score.
studentsis a list containing dictionaries.Each dictionary represents one student with two pieces of information:
"name"→ the student’s name"score"→ their test score
The
forloop goes through each student dictionary one by one.Inside the loop:
student['name']gets the student’s name.student['score']gets their score.
The
print()statement displays both pieces of data in one sentence.