Portrait of Henry VIII
There have been 66 monarchs of England and Britain spread over a period of 1500 years.
For this Python challenge you will use a text file listing all of these monarchs in chronological order. You will then write a Python program to prompt the user to enter a year (between 757 and 2017) and your program will look up for the name of the monarch of England at the given date.
To complete this challenge you will need to read more about how to read through a CSV file.
The text file we will use contains one line per monarch. On each line it stores the year the reign started, the year it ended and the name of the monarch as follows:
Monarchs-of-England.csv
Complete the Code
Testing
Once you have completed the code check that it produces the expected output by performing the following tests:
Test # | Input Values | Expected Output | Actual Output |
#1 | 1192 | Richard I | |
#2 | 1345 | Edward III | |
#3 | 1042 | Harthacanut Edward the Confessor |
|
#4 | 1547 | Henry VIII Edward VI |
|
#5 | 1016 | Ethelred II the Unready Edmund lronsideCnut (Canute) |
|
#6 | 512 | Not Found |
Extension Task:
Tweak the output of your program so that when giving the name of the monarch matching the year entered, your program also mentions who were the previous monarch and the next monarch.
For instance the output of the program could be:
Video Tutorial
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area