States and Capitals: 'Alabama': 'Montgomery', 'Alaska': 'Juneau','Arizona':'Phoenix', 'Arkansas':'Little Rock', 'California': 'Sacramento', 'Colorado':'Denver', 'Connecticut':'Hartford', 'Delaware':'Dover','Florida': 'Tallahassee', 'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinios': 'Springfield', 'Indiana': 'Indianapolis','Iowa': 'Des Monies', 'Kansas': 'Topeka','Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine': 'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', 'Michigan': 'Lansing', 'Minnesota': 'St. Paul', 'Mississippi': 'Jackson', 'Missouri': 'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln', 'Neveda': 'Carson City', 'New Hampshire': 'Concord', 'New Jersey': 'Trenton', 'New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh', 'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City', 'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhoda Island': 'Providence', 'South Carolina': 'Columbia', 'South Dakoda': 'Pierre', 'Tennessee': 'Nashville', 'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont': 'Montpelier', 'Virginia': 'Richmond', 'Washington': 'Olympia', 'West Virginia': 'Charleston', 'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter19: Probabilistic Dynamic Programming
Section19.4: Further Examples Of Probabilistic Dynamic Programming Formulations
Problem 7P
icon
Related questions
Question

States and Capitals:
'Alabama': 'Montgomery', 'Alaska': 'Juneau','Arizona':'Phoenix',
'Arkansas':'Little Rock', 'California': 'Sacramento', 'Colorado':'Denver',
'Connecticut':'Hartford', 'Delaware':'Dover','Florida': 'Tallahassee',
'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise',
'Illinios': 'Springfield', 'Indiana': 'Indianapolis','Iowa': 'Des Monies',
'Kansas': 'Topeka','Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge',
'Maine': 'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston',
'Michigan': 'Lansing', 'Minnesota': 'St. Paul', 'Mississippi': 'Jackson',
'Missouri': 'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln',
'Neveda': 'Carson City', 'New Hampshire': 'Concord', 'New Jersey': 'Trenton',
'New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh',
'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City',
'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhoda Island': 'Providence',
'South Carolina': 'Columbia', 'South Dakoda': 'Pierre', 'Tennessee': 'Nashville',
'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont': 'Montpelier',
'Virginia': 'Richmond', 'Washington': 'Olympia', 'West Virginia': 'Charleston',
'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'

Create the following program to create a quiz asking users the state capital of states in US:
fCreateDictionary:
Create a dictionary object using US state as key and capitol as value (see below)
Return the dictionary object
fStateRandomizer:
•
fPlay:
main():
Create parameter pStates Capitals to receive the states/capitals dictionary object
Use method popitem to return a key-value pair
Create parameter pStatesCapitals to receive the states/capitals dictionary object
Create a for loop to loop over all elements of the dictionary object
Within the loop, call fStateRandomizer and assign the returned key value pair in variables state and
capital
Ask the user for the capital of the state displayed in the prompt of an input statement (see below) and
stored it in variable answer
Compare the answer to the capital variable (case insensitive) and produce the output shown below:
.
If answer is correct, keep track of correct answers
. If answer is incorrect, show the correct answer (see below)
Ask the user whether to play again or not, if no use break statement to exit the loop
Return a string displaying the number of correct answers (see below)
Call function fCreateDictionary and pass returned dictionary object into fPlay
Display the returned string from fPlay
Transcribed Image Text:Create the following program to create a quiz asking users the state capital of states in US: fCreateDictionary: Create a dictionary object using US state as key and capitol as value (see below) Return the dictionary object fStateRandomizer: • fPlay: main(): Create parameter pStates Capitals to receive the states/capitals dictionary object Use method popitem to return a key-value pair Create parameter pStatesCapitals to receive the states/capitals dictionary object Create a for loop to loop over all elements of the dictionary object Within the loop, call fStateRandomizer and assign the returned key value pair in variables state and capital Ask the user for the capital of the state displayed in the prompt of an input statement (see below) and stored it in variable answer Compare the answer to the capital variable (case insensitive) and produce the output shown below: . If answer is correct, keep track of correct answers . If answer is incorrect, show the correct answer (see below) Ask the user whether to play again or not, if no use break statement to exit the loop Return a string displaying the number of correct answers (see below) Call function fCreateDictionary and pass returned dictionary object into fPlay Display the returned string from fPlay
States and Capitals:
'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona':'Phoenix',
'Arkansas': "Little Rock', 'California': 'Sacramento', 'Colorado':'Denver',
'Connecticut': 'Hartford', 'Delaware":"Dover','Florida': 'Tallahassee',
'Georgia': 'Atlanta', Hawaii': 'Honolulu', 'Idaho': 'Boise',
'Illinios': 'Springfield', 'Indiana': 'Indianapolis','Iowa': 'Des Monies',
Kansas': 'Topeka', 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge',
'Maine': 'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston',
'Michigan': 'Lansing', 'Minnesota': 'St. Paul', 'Mississippi': 'Jackson',
'Missouri': 'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln',
Neveda': 'Carson City', New Hampshire': 'Concord', 'New Jersey': "Trenton',
New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh',
'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City',
'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhoda Island': 'Providence',
'South Carolina': 'Columbia', 'South Dakoda': Pierre', 'Tennessee': 'Nashville',
'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont': 'Montpelier',
'Virginia': 'Richmond', 'Washington': 'Olympia', 'West Virginia': 'Charleston',
'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'
Transcribed Image Text:States and Capitals: 'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona':'Phoenix', 'Arkansas': "Little Rock', 'California': 'Sacramento', 'Colorado':'Denver', 'Connecticut': 'Hartford', 'Delaware":"Dover','Florida': 'Tallahassee', 'Georgia': 'Atlanta', Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinios': 'Springfield', 'Indiana': 'Indianapolis','Iowa': 'Des Monies', Kansas': 'Topeka', 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine': 'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', 'Michigan': 'Lansing', 'Minnesota': 'St. Paul', 'Mississippi': 'Jackson', 'Missouri': 'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln', Neveda': 'Carson City', New Hampshire': 'Concord', 'New Jersey': "Trenton', New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh', 'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City', 'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhoda Island': 'Providence', 'South Carolina': 'Columbia', 'South Dakoda': Pierre', 'Tennessee': 'Nashville', 'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont': 'Montpelier', 'Virginia': 'Richmond', 'Washington': 'Olympia', 'West Virginia': 'Charleston', 'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Fundamentals of Information Systems
Fundamentals of Information Systems
Computer Science
ISBN:
9781305082168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning