Using the Dictionary below, create a game that picks a random number based on the length of the dictonary. Using that random number, prompts the user for the capital of that state (the key for your dictionary) - Use the code snipet below Your program must prompt the user by asking "What is the capital of XXX:" and XXX is the state name. Your program should compare the guess to the actual capital for that state. If the guess is correct, increment the number of correct guesses. If the guess is wrong, increment the numner of incorrect guesses. When the user types in quit in eithe uppercase or lowercase, the program should print out the results of the game by telling the payer you had XX correct responses and YY incorrect responses. Then the program should end. Make sure to do the Outline and Logic parts for your program. You can include your Python code in yout Word document, or submit it as a Python (;py) file Upload your work to this assignment when completed. # Pick random number and pick the capital for the player import random - Put this at the top of your code rand_capital = random.randint(0,len(capitals)) capital_list = list(capitals) capital = capital_list[rand_capital] print(capital) # Initialize dictionary 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', 'Illinois':'Springfield', 'Indiana':'Indianapolis', 'Iowa':'Des Moines', 'Kansas':'Topeka', 'Kentucky':'Frankfort', 'Louisiana':'Baton Rouge', 'Maine':'Augusta', 'Maryland':'Annapolis', 'Massachusetts':'Boston', 'Michigan':'Lansing', 'Minnesota':'Saint Paul', 'Mississippi':'Jackson', 'Missouri':'Jefferson City', 'Montana':'Helena', 'Nebraska':'Lincoln', 'Nevada':'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', 'Rhode Island':'Providence', 'South Carolina':'Columbia', 'South Dakota':'Pierre', 'Tennessee':'Nashville', 'Texas':'Austin', 'Utah':'Salt Lake City', 'Vermont':'Montpelier', 'Virginia':'Richmond', 'Washington':'Olympia', 'West Virginia':'Charleston', 'Wisconsin':'Madison', 'Wyoming':'Cheyenne'}
Using the Dictionary below, create a game that picks a random number based on the length of the dictonary. Using that random number, prompts the user for the capital of that state (the key for your dictionary) - Use the code snipet below Your program must prompt the user by asking "What is the capital of XXX:" and XXX is the state name. Your program should compare the guess to the actual capital for that state. If the guess is correct, increment the number of correct guesses. If the guess is wrong, increment the numner of incorrect guesses. When the user types in quit in eithe uppercase or lowercase, the program should print out the results of the game by telling the payer you had XX correct responses and YY incorrect responses. Then the program should end. Make sure to do the Outline and Logic parts for your program. You can include your Python code in yout Word document, or submit it as a Python (;py) file Upload your work to this assignment when completed. # Pick random number and pick the capital for the player import random - Put this at the top of your code rand_capital = random.randint(0,len(capitals)) capital_list = list(capitals) capital = capital_list[rand_capital] print(capital) # Initialize dictionary 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', 'Illinois':'Springfield', 'Indiana':'Indianapolis', 'Iowa':'Des Moines', 'Kansas':'Topeka', 'Kentucky':'Frankfort', 'Louisiana':'Baton Rouge', 'Maine':'Augusta', 'Maryland':'Annapolis', 'Massachusetts':'Boston', 'Michigan':'Lansing', 'Minnesota':'Saint Paul', 'Mississippi':'Jackson', 'Missouri':'Jefferson City', 'Montana':'Helena', 'Nebraska':'Lincoln', 'Nevada':'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', 'Rhode Island':'Providence', 'South Carolina':'Columbia', 'South Dakota':'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
Related questions
Question
Using the Dictionary below, create a game that picks a random number based on the length of the dictonary.
Using that random number, prompts the user for the capital of that state (the key for your dictionary) - Use the code snipet below
Your program must prompt the user by asking "What is the capital of XXX:" and XXX is the state name.
Your program should compare the guess to the actual capital for that state.
If the guess is correct, increment the number of correct guesses.
If the guess is wrong, increment the numner of incorrect guesses.
When the user types in quit in eithe uppercase or lowercase, the program should print out the results of the game by telling the payer you had XX correct responses and YY incorrect responses.
Then the program should end.
Make sure to do the Outline and Logic parts for your program.
You can include your Python code in yout Word document, or submit it as a Python (;py) file
Upload your work to this assignment when completed.
# Pick random number and pick the capital for the player
import random - Put this at the top of your code
rand_capital = random.randint(0,len(capitals))
capital_list = list(capitals)
capital = capital_list[rand_capital]
print(capital)
capital_list = list(capitals)
capital = capital_list[rand_capital]
print(capital)
# Initialize dictionary
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',
'Illinois':'Springfield', 'Indiana':'Indianapolis',
'Iowa':'Des Moines', 'Kansas':'Topeka',
'Kentucky':'Frankfort', 'Louisiana':'Baton Rouge',
'Maine':'Augusta', 'Maryland':'Annapolis',
'Massachusetts':'Boston', 'Michigan':'Lansing',
'Minnesota':'Saint Paul', 'Mississippi':'Jackson',
'Missouri':'Jefferson City', 'Montana':'Helena',
'Nebraska':'Lincoln', 'Nevada':'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',
'Rhode Island':'Providence', 'South Carolina':'Columbia',
'South Dakota':'Pierre', 'Tennessee':'Nashville',
'Texas':'Austin', 'Utah':'Salt Lake City',
'Vermont':'Montpelier', 'Virginia':'Richmond',
'Washington':'Olympia', 'West Virginia':'Charleston',
'Wisconsin':'Madison', 'Wyoming':'Cheyenne'}
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',
'Illinois':'Springfield', 'Indiana':'Indianapolis',
'Iowa':'Des Moines', 'Kansas':'Topeka',
'Kentucky':'Frankfort', 'Louisiana':'Baton Rouge',
'Maine':'Augusta', 'Maryland':'Annapolis',
'Massachusetts':'Boston', 'Michigan':'Lansing',
'Minnesota':'Saint Paul', 'Mississippi':'Jackson',
'Missouri':'Jefferson City', 'Montana':'Helena',
'Nebraska':'Lincoln', 'Nevada':'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',
'Rhode Island':'Providence', 'South Carolina':'Columbia',
'South Dakota':'Pierre', 'Tennessee':'Nashville',
'Texas':'Austin', 'Utah':'Salt Lake City',
'Vermont':'Montpelier', 'Virginia':'Richmond',
'Washington':'Olympia', 'West Virginia':'Charleston',
'Wisconsin':'Madison', 'Wyoming':'Cheyenne'}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education