Solved by verified expert:CS118 Dictionary Homework
cs118_hw6_2017dictionary.doc
Unformatted Attachment Preview
CS118 Dictionary Homework
➢ Copy the statesAndCapitals dictionary below into your program.
statesAndCapitals={ “Alabama”: “Montgomery”,
“Georgia”: “Atlanta”,
“Arizona”: “Phoenix”,
“Arkansas”: “Little Rock”,
“California”: “Sacramento”,
“Ohio”: “Columbus”,
“Connecticut”: “Hartford” }
➢ Use the dictionary contents to give a states and capitals quiz. Let the user
know whether each answer is correct or incorrect.
➢ Add 3 more states and capitals to the dictionary in your Python code.
➢ Keep track of a final score for the quiz.
The program might look something like this when you run it several times
(program output in blue, what you type at the keyboard in black).
>>>
>>>
What is the capital of Arizona? Phoenix
Correct!
What is the capital of Connecticut? Hartford
Correct!
What is the capital of Colorado? Denver
Correct!
What is the capital of California? Sacramento
Correct!
What is the capital of Alaska? I forget
Incorrect. The answer was Juneau
What is the capital of Arkansas? Little Rock
Correct!
What is the capital of Alabama? abc
Incorrect. The answer was Montgomery
***Your score is : 5 out of 7
…
Purchase answer to see full
attachment