Question
write this code in python format without using a break statement and screen shot the code for the result. Here is a .txt file that
write this code in python format without using a break statement and screen shot the code for the result.
Here is a .txt file that has a list of US states and capitals (USStatesCapitals.txt) on blackboard. Write a program that reads this file and creates a dictionary with states and capitals as key-value pairs. The program should then randomly quiz the user by displaying the name of a state and asking the user to enter that states capital.
Hint: For getting a key-value pair randomly from a dictionary, check the random.sample() function from the random module.
this is the file on blackboard which is USStatesCapitals.txt
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,St. 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started