Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Develop code

EasyMediumHard
123456789101112
Question 12

Marcus is a running club coach.

He wants a program to analyse his members' weekly training distances (in km) to help them prepare for an upcoming half-marathon.

He wants to award Gold, Silver, and Bronze virtual badges to the three runners who cover the furthest distance, and also identify runners who may need extra support because they covered less than 12 km.

The program should process a structured dataset. Here is an example of the dataset included in the code:

# Test data
runners = [
    {"id": "R203", "distance": 28.5},
    {"id": "R109", "distance": 9.2},
    {"id": "R402", "distance": 42.1},
    {"id": "R115", "distance": 11.8},
    {"id": "R301", "distance": 35.0},
    {"id": "R504", "distance": 6.4},
    {"id": "R220", "distance": 31.7}
]

Write a program in Python or an exam-style pseudocode to calculate and display:

  1. The total distance and the average distance run by all members.
  2. The IDs of members who have run fewer than 12 km.
  3. The IDs and distances of the Gold, Silver, and Bronze badge winners (the top three longest distances).

Your program must work dynamically even if the number of runners in the dataset changes.

[20]

Develop code Questions

  1. IGCSE
  2. /Computer Science
  3. /Develop code