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
Basics AutoCare is a small auto service business with two locations in a Midwest (U.S.) city. The business is based on providing
kogti [31]

Answer:

The ER diagram for the auto service is shown in the attachment.

5 0
3 years ago
which classification of money describes money that can be accessed quickly and easily, and includes coins and paper money as wel
zhenek [66]

Money that can be promptly and easily appraised falls under the M1 Money classification.

<h3>What are broad and narrow money, respectively?</h3>

Broad money typically refers to M2, M3, and/or M4. The most liquid kinds of money, such as currency (banknotes and coins), as well as bank account balances that may be instantly changed into currency or used for cashless transactions, are generally referred to as "narrow money" (overnight deposits, checking accounts).

<h3>Describe Narrow Money.</h3>

All of the actual money that the central bank has falls under the category of "narrow money," which is a subset of the money supply. Demand deposits, money, and other liquid assets are included. In the US, "narrow money" is referred to as M1 (M0 plus demand accounts).

To know more about Money classification visit:-

brainly.com/question/28095328

#SPJ1

5 0
1 year ago
Robin maintains a web page for updating the metro timings in the city. He would like the website to display the present day's sc
Paladinen [302]
The answer : B 4 is the value of the month that will be displayed on the web page
8 0
3 years ago
I figured out the secret message in Dad feels good, I can connect the dots
kati45 [8]

Answer:

Nope you figured it out

Explanation:

3 0
3 years ago
The first tools that analyzed and extracted data from floppy disks and hard disks were MS-DOS tools for ____ PC file systems.
netineya [11]

<u>The first tools that analyzed and extracted data from floppy disks and hard disks were MS-DOS tools for </u><u>IBM</u><u> PC file systems</u>. A file system is a structured representation of data and a set of metadata describing this data. The file system of the IBM supports stream input/output and storage management, providing a structure over all information stored in the system. A floppy disk consists of a thin plastic disk coated with magnetic material (it was designed by IBM in the early 1970s). A hard disk is fixed on the system unit. It is made up of several circular disks called platters. MS-DOS (Microsoft Disk Operating System) is a licensed operating system for use on microcomputers from various manufacturers.

6 0
3 years ago
Other questions:
  • Given a int variable named yesCount and another int variable named noCount and a char variable named response, write the necessa
    9·1 answer
  • A teacher uses the spreadsheet below to determine the average quiz score of each student. The teacher inserts this information i
    11·2 answers
  • You start up your laptop while getting a coffee across the room. You hear the usual chimes and doinks as it starts up. When you
    14·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    11·2 answers
  • Your mom wants to purchase a computer. She has heard about how the Windows 8 operating system is best-geared for a touch-enabled
    10·2 answers
  • What data discovery process, whereby objects are categorized into predetermined groups, is used in text mining?
    9·1 answer
  • A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the clie
    8·1 answer
  • Some applications required advanced storage solutions are available to provide fault tolerance and high performance.
    13·1 answer
  • How does this happen on brianly???
    5·2 answers
  • In Python, what does this command do:<br>print ("\n")​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!