Solution: Class Grades
Explore how to store student data using lists of dictionaries in Python. Learn to retrieve and print each student’s name and score with a for loop, gaining practical skills in organizing and accessing structured data.
We'll cover the following...
We'll cover the following...
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.