In particular, this project will cover the following concepts we have discussed in class:
To play the Geography game, two players alternately say the names of a country in the world. There are a few restrictions. A player must respond by saying the name of a country where the first letter matches the last letter of the country said by the other player. Also, once a country name is chosen, it cannot be used again. The first player to be stumped loses the game.
You will program this game for a user to play against a computer opponent. An example game is as follows:
User: Botswana Computer: Algeria User: Afganistan Computer: Norway User: Yemen Computer: Nigeria User: Angola Computer: Albania User: I GIVE UP Computer: I Win! You could have said Austria.
The computer will choose the first valid word in the country list that matches alphabetically.
The computer will choose a random valid country.
Both the user and computer cannot choose countries that end in O, Q, W, X, Y or Z. If possible, the computer will choose a random valid country that has no possible response from the user, otherwise the computer will choose a random valid country.
You must create a python program
called geography.py
. It will:
Your code should make good use of functions, as there are clear pieces of the game which are repeated. Using functions will reduce the amount of code you need to write as well as make your program easier to debug. However, do not write spaghetti code, where functions call each other back and forth to continue execution of the program; let your functions naturally return values and use loops to repeat the game turns.
Your code must check all user input for validity and reprompt them for correct input if any mistakes are made.
cs.centenary.edu
through either Secure FTP or WinSCP using your
cs login and password. Copy your geography.py
project into the project2
directory, along with any other files
you need to run your code. Make sure
you have followed the Python Style Guide, and
have run your project through the Automated Style Checker.You must hand in: