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'

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education