Question: Python: Using functions write a program that creates a dictionary containing the US states as keys and their capitals as values. The program should randomly
Python:
Using functions write a program that creates a dictionary containing the US states as keys and their capitals as values.
The program should randomly quiz the user by displaying the name of a state and asking the user to enter that states capital.
It should keep a count of the number of correct and incorrect responses and let the user know how they are doing.
It should not penalize the user for capitalization errors.
It should also not ask a user about a state if they have already correctly identified the capital (if they have not, it can ask them again). If, instead of guessing, the user types 0, the game should quit and tell them their score.
Example program outputs:
What is the capital of Illinois? (or enter 0 to quit): springfield
That is correct.
What is the capital of Pennsylvania? (or enter 0 to quit): Pittsburgh
That is incorrect. It is Harrisburg.
What is the capital of North Dakota? (or enter 0 to quit): bismarck
That is correct. What is the capital of Nevada? (or enter 0 to quit): Las Vegas
That is incorrect. It is Carson City.
What is the capital of Iowa? (or enter 0 to quit): 0
You had 2 correct responses and 2 incorrect responses.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
