1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Debora [2.8K]
2 years ago
7

Write a program that creates a dictionary containing the U.S. states as keys and their abbreviations as values. The program shou

ld then randomly quiz the user by displaying the abbreviation and asking the user to enter that state's name. The program should keep a count of the number of correct and incorrect responses, as well as which abbreviation the user missed. You should include the following: Mainline logic and functions Error handling Dictionaries
Computers and Technology
1 answer:
AleksandrR [38]2 years ago
6 0

Answer:

Explanation:

The following program is written in Python. It creates a loop that keeps creating a random number to randomly choose a State abbreviation from the dictionary. Then it asks the user what the state is. If the user gets the answer correct it prints out "Correct" and adds 1 point to the correct variables. Otherwise it prints "Incorrect" and adds 1 point to the incorrect variable. Finally, printing out the final amount of correct and incorrect responses. The program was tested and the output can be seen below.

import random

states = {"AL":"Alabama","AK":"Alaska","AZ":"Arizona","AR":"Arkansas","CA":"California","CO":"Colorado","CT":"Connecticut","DE":"Delaware","FL":"Florida","GA":"Georgia","HI":"Hawaii","ID":"Idaho","IL":"Illinois","IN":"Indiana","IA":"Iowa","KS":"Kansas","KY":"Kentucky","LA":"Louisiana","ME":"Maine","MD":"Maryland","MA":"Massachusetts","MI":"Michigan","MN":"Minnesota","MS":"Mississippi","MO":"Missouri","MT":"Montana","NE":"Nebraska","NV":"Nevada","NH":"New Hampshire","NJ":"New Jersey","NM":"New Mexico","NY":"New York","NC":"North Carolina","ND":"North Dakota","OH":"Ohio","OK":"Oklahoma","OR":"Oregon","PA":"Pennsylvania","RI":"Rhode Island","SC":"South Carolina","SD":"South Dakota","TN":"Tennessee","TX":"Texas","UT":"Utah","VT":"Vermont","VA":"Virginia","WA":"Washington","WV":"West Virginia","WI":"Wisconsin","WY":"Wyoming"}

keys_list = list(states)

correct = 0

incorrect = 0

while True:

   randNum = random.randint(0, 49)

   abbr = keys_list[randNum]

   answer = input("Enter The State name of " + abbr + ": ")

   if answer.lower() == states[abbr].lower():

       print("Correct")

       correct += 1

   else:

       print("Incorrect")

       incorrect += 1

   again = input("Play again? y/n ")

   if again.lower() == 'n':

       break

print("Correct: " + str(correct))

print("Incorrect: " + str(incorrect))

You might be interested in
For businesses and organizations under recent compliance laws, data classification standards typically include private, confiden
Mnenie [13.5K]
Answer: True






Explanation:
6 0
3 years ago
The ________________ Act requires Internet sales to be treated in the same way as mail-order sales (e.g., collect sales tax from
BARSIC [14]

Answer:

Internet Tax Freedom Act

Explanation:

The Internet Tax Freedom Act was signed into law in 1998 by President Bill Clinton and has since been reviewed until the Permanent Internet Tax Freedom Act was passed into law on the 9th of June, 2015 by President Barrack Obama.

The Act requires that internet sales are equally treated as mail-order sales.

5 0
3 years ago
Anyone wanna join a supercar/hypercar enthusiast's club?
stellarik [79]

Answer:

I have Lamborghini Centenario as my profile pic. :)

Explanation:

7 0
3 years ago
Abby wants to simply share a snapshot of her calendar with another user. Which option should she choose to achieve this
Papessa [141]

Answer:

Screenshot

Explanation:

Just a guess

8 0
3 years ago
Read 2 more answers
Which component of the computer keeps the operating system when the computer is running​
Brums [2.3K]

The CPU performs the instructions and writes the data back into your computer's random access memory or RAM. RAM temporarily stores data while your computer is running.

4 0
3 years ago
Other questions:
  • In Python, what kind of error is returned by the following code? (e.g. NameError, ValueError, IOError, etc.) def my_func(n1, n2)
    8·1 answer
  • What are some of the challenges that could arise from setting up a file management system on a computer?
    11·1 answer
  • I can create spreadsheets in Google Draw. False True
    14·2 answers
  • What inventor patented the first american movie projector
    15·2 answers
  • Which of the following data recording procedures is best used for behaviors that have a clear ending and beginning, do not occur
    12·1 answer
  • SLA:
    14·1 answer
  • . When attempting to minimize memory usage, the most efficient way to do group processing when using the MEANS procedure is to u
    13·1 answer
  • What are the main components of a desktop PC and briefly describe their purposes.​
    14·1 answer
  • During the ___ phase of a software development project, members broadly define the features that the software should include
    15·1 answer
  • A company is looking for an employee to design and test connections in its
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!