Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Working with Lists of Athlete Records | Tracking Athlete Performance
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Coaches

bookWorking with Lists of Athlete Records

Managing a team of athletes often means keeping track of a lot of data—names, performance metrics, and progress over time. In Python, you can organize this information efficiently by using a list of dictionaries, where each dictionary represents an athlete and their individual stats. This structure makes it easy to store, access, and update each athlete's information, which is especially useful when you need to manage data for an entire team or compare athletes side by side.

1234567891011121314151617181920
athletes = [ { "name": "Jordan Lee", "speed": [7.2, 7.5, 7.3], # Weekly speed in mph "endurance": 85, # Endurance score out of 100 "attendance": 3 }, { "name": "Morgan Cruz", "speed": [6.8, 7.1, 7.0], "endurance": 90, "attendance": 2 }, { "name": "Taylor Kim", "speed": [7.4, 7.6, 7.8], "endurance": 88, "attendance": 3 } ]
copy

By organizing your data this way, you can easily loop through the list to access or update each athlete's record. Iterating through the list allows you to perform actions such as printing all athletes' names, calculating averages, or modifying stats based on new results. This approach is scalable, meaning you can add or remove athletes without changing how you process the list.

123
for athlete in athletes: avg_speed = sum(athlete["speed"]) / len(athlete["speed"]) print(f"{athlete['name']}: Average weekly speed is {avg_speed:.2f} mph")
copy

1. What Python data structure is best for storing multiple athlete records?

2. How can you access the endurance value for the second athlete in the list?

3. What is the benefit of using a loop to process athlete data?

question mark

What Python data structure is best for storing multiple athlete records?

Select the correct answer

question mark

How can you access the endurance value for the second athlete in the list?

Select the correct answer

question mark

What is the benefit of using a loop to process athlete data?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 2

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

How can I add a new athlete to the list?

Can you show me how to update an athlete's stats?

How do I calculate the average endurance score for the team?

bookWorking with Lists of Athlete Records

Sveip for å vise menyen

Managing a team of athletes often means keeping track of a lot of data—names, performance metrics, and progress over time. In Python, you can organize this information efficiently by using a list of dictionaries, where each dictionary represents an athlete and their individual stats. This structure makes it easy to store, access, and update each athlete's information, which is especially useful when you need to manage data for an entire team or compare athletes side by side.

1234567891011121314151617181920
athletes = [ { "name": "Jordan Lee", "speed": [7.2, 7.5, 7.3], # Weekly speed in mph "endurance": 85, # Endurance score out of 100 "attendance": 3 }, { "name": "Morgan Cruz", "speed": [6.8, 7.1, 7.0], "endurance": 90, "attendance": 2 }, { "name": "Taylor Kim", "speed": [7.4, 7.6, 7.8], "endurance": 88, "attendance": 3 } ]
copy

By organizing your data this way, you can easily loop through the list to access or update each athlete's record. Iterating through the list allows you to perform actions such as printing all athletes' names, calculating averages, or modifying stats based on new results. This approach is scalable, meaning you can add or remove athletes without changing how you process the list.

123
for athlete in athletes: avg_speed = sum(athlete["speed"]) / len(athlete["speed"]) print(f"{athlete['name']}: Average weekly speed is {avg_speed:.2f} mph")
copy

1. What Python data structure is best for storing multiple athlete records?

2. How can you access the endurance value for the second athlete in the list?

3. What is the benefit of using a loop to process athlete data?

question mark

What Python data structure is best for storing multiple athlete records?

Select the correct answer

question mark

How can you access the endurance value for the second athlete in the list?

Select the correct answer

question mark

What is the benefit of using a loop to process athlete data?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 2
some-alt