Learning Objectives
In this challenge we are going to investigate methods that can be used to:
- Read and extract data from a text file,
- Sort this data in ascending or descending order,
- Display this sorted data on screen.
Context
We have a text file with the list of the 10 top countries at the London 2012 Olympic Games. (Countries which won the most gold medals). This data is not sorted and is organised as follows:
You can download this text file:
Step by Step
To achieve our goal of reading the text file, sorting its data and displaying it on the screen we will proceed in 5 steps:
Python Code
Your Challenge
Tweak this code to:
- Sort this list in ascending order of gold medals
- Sort this list in alphabetical (ascending) order of name of country
- Sort this list in descending order of silver medals
- Sort this list in descending order of bronze medals
- Sort this list in descending order of total number of medals (Bronze + Silver + Gold medals)
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area