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]
3 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]3 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
A metacharacter is a character that has a special meaning assigned to it and is recognized as part of a scripting or programming
nydimaria [60]

Answer:

The answer is "Option a"

Explanation:

Meta-character is a unique character, which is used in the system or information area, that provides information about the other characters. This type of character is used in both command-line and programming.  

  • It has a particular meaning and should be prevented for reasons except for its particular importance.
  • It attempts in the algorithmic technique to view all character as a fundamental ASCII instead of a specific purpose.
3 0
3 years ago
A company that connects through your communications line to its server, which connects you to the Internet, is a(n)
hammer [34]
Internet server provider
4 0
3 years ago
The query [windows], English (US) has two dominant interpretations: the operating system and the windows in a home.
Flauer [41]

Answer:

B. False

Explanation:

Microsoft Windows is a graphics user interface operating system that uses windows query to search for information in its directory. There are different versions and updates of the windows OS, with latest being window 10 1903. The different version of the windows 10 OS is windows professional, Home, Enterprise etc. As time goes on, more updates will be released for better and advanced security.

3 0
4 years ago
Assume Flash Sort is being used on a array of integers with Amin = 51, Amax = 71, N=10, m=5 Items are classified according to th
Yuliya22 [10]

Answer:

3

Explanation:

= 1 + (int) (4*(63 - 51)/(71-51)))

= 1 + (int) (4*12/20)

= 1 + (int) (48/20)

= 1 + (int)2.4

= 1 + 2

= 3

8 0
3 years ago
One of the most toxic components of a computer is the _________.a. plastic in the keyboardb. silicon in the glass of the compute
Burka [1]

Answer:

C. Lead embedded in the glass of the monitor.

Explanation:

Cathode Ray Tube (CRT) monitors have lead embedded in their glass. Exposure to small quantities of lead can lead to lead poisoning. There are about 2.2 kilograms of lead in a big CRT monitor.

This amount of lead is mixed with the glass to improve the optical quality and to stop radiation from affecting the user.

Exposure to lead can cause the following:

  1. Constipation.
  2. Irritability,
  3. Headaches
  4. Aggressive behavior and so much more.
3 0
4 years ago
Read 2 more answers
Other questions:
  • Categorize the following relationships into generalization, aggregation, or association. Beware, there may be n-ary associations
    14·1 answer
  • When you record a macro, you can assign it to run from a button or from the _____.
    9·2 answers
  • Complete the sentence.
    7·1 answer
  • The general case in a recursive function is the case for which the solution is obtained directly.
    9·1 answer
  • In order to increase typing speed Minisoft has redesigned its keyboard and provided a chime that is related to typing speed. The
    10·1 answer
  • Oliver’s night job at the university computing center is to change the tapes used for overnight data backups on the server. Whil
    9·1 answer
  • In the following code, what values could be read into number to terminate the while loop? Scanner keyboard = new Scanner(System.
    8·1 answer
  • A user program executes in a __________ , in which certain areas of memory are protected from the user's use, and in which certa
    12·1 answer
  • Html code to hyperlink home.html​
    5·1 answer
  • Why do we create user accounts to customize our preferences​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!