US Presidents Quiz

american-presidentSince the establishment of the United States of America, in 1789, 45 people have served as president, the first one being George Washington.

For this challenge you will use a text file listing all of these US presidents in chronological order. (See text file below.) You will then write a Python program to randomly pick two presidents from this list of 45 presidents. Your program will display the name of both presidents and ask the end-user who is the most recent president amongst the two presidents being displayed. For instance the program will output the following question:

Who was the most recent president?
A) John F. Kennedy or B) Richard Nixon.

The game carries on as long as the user is correct. For each correct answer the user will score 10 points. The game ends once the user gets a wrong answer.

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 US President. On each line it stores a number (position from 1 to 45), the name of te president, the year their presidency started, the year it ended as follows:


Complete the Code


When asking the question, give the user the option to ask for a clue (by typing answer C). When the user asks for a clue, the program will output the starting and ending date of the presidency of one of the two presidents. The user will then have to answer the intial question.

Share Button
Posted in Computer Science, Python - Intermediate, Python Challenges

Our Latest Book