Challenge 3: World records
Suggested time: 30 minutes
A programmer is researching food related world records. They have a 2d list which stores:
- the name of the record holder (e.g. Andre Ortolf)
- the quantity of food consumed (e.g. 378)
- the unit used to measure the quantity of food consumed (e.g grams)
- the food consumed (e.g. peanut butter)
- the time taken (e.g. 1)
- the unit of time taken (e.g. minute)
The program should display the world records on screen exactly as shown below
The program should also write the world records to the file output.txt
formatted as a table. Each column should be separated by a |
character. All columns must be centre aligned. The width of each column (not including the |
characters should be 30 characters (Name), 50 characters (Food) and 30 characters (Time). The total width of the table should be 114 characters:
Using the file Q06.py below:
Amend the program to meet the following requirements:
- Display the world records on screen in sentences as shown above
- Write the world records to the file
output.txt
as shown above - Use comments, whitespace, local variables subprograms
- Use string formatting to centre align the columns in the table
Do not change any other functionality.
If this was a real question it would tell you to save your code as Q06_FINISHED.py but you might want to save your code so you can show your teacher or come back to it later by pressing Ctrl + S or clicking on the icon that looks like this: