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
In 3–5 sentences, describe how technology helps business professionals to be more efficient.
quester [9]

Answer:

Technology helps business professionals, keep more organized, communicate better, and effectively keeps businesses secure. Technology helps keep employee information and business paper work more organized using computers and software; while making it easier to communicate with employee's using e-mail and memo's.

Explanation:

8 0
3 years ago
Read 2 more answers
What is word processing?
butalik [34]
A. Citing sources for documents you found on the web
3 0
3 years ago
Read 2 more answers
Which of the following galaxy types is most likely to be clearly identifiable, regardless of orientation? SBc
Reil [10]

Answer:

The most likely galaxy type to be identifiable regardless of orientation is: Irr

Explanation:

The Irr galaxies don't have a discernable or usual shape; that is why it is relatively easy to identify.

When we talk about E type galaxies, this statement proves itself by the way the cumulus of stars compounds the galaxy. The elliptical galaxies have the form of ellipses, with a reasonable distribution of stars. The degree of eccentricity is the number that complements the E letter; that's why E0 galaxies are almost spherical, while E7 is considerably elongated.

SBc, SBa galaxies are spiral; this means it can be flat in some angles difficulting their identification process; in this case, the last letter means the way the arms display their form, with "c" having a vague form and "a" well-defined arms. That's why in some angles can be mistreated as another type of galaxy.

3 0
3 years ago
You can add additional design elements to a picture by adding a color background, which is accomplished by using what Paint feat
katrin2010 [14]

Answer:

Fill with Color tool

6 0
3 years ago
Mitchell doesn’t have a checking account, but needs to pay a bill, what can Mitchell pay with?
aleksandr82 [10.1K]
Cash, possibly credit card.
5 0
3 years ago
Read 2 more answers
Other questions:
  • Write the definition of a function typing_speed, that receives two parameters. The first is the number of words that a person ha
    9·1 answer
  • The local emergency manager has the responsibility for coordinating emergency management programs and activities. A local emerge
    7·1 answer
  • Below is a 4-bit down-counter. What is the largest number of the counter if the initial state Q3Q2Q1Q0=0011? (D3 and Q3 are MSB,
    14·1 answer
  • Where should you click to edit an existing formula?
    12·2 answers
  • Help with this robotics hw pls
    5·1 answer
  • You have important data on your hard drive that is not backed up and your Windows installation is so corrupted you know that you
    6·1 answer
  • What is a computer dedicated to a single function, such as a calculator or computer game? A. TabletB. PDAC.ApplianceD. Minicompu
    6·1 answer
  • What is the significance of the Abstract section of a research paper? A. It contains important information such as the author, c
    5·1 answer
  • How do you start using the Internet?
    6·2 answers
  • Steps to copy and paste text/information from website to Ms-word using keyboard​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!