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
Sharon is thinking about opening a bakery. She knows she wants to set her own hours, reduce her stress and make a profit. But sh
kondaur [170]
C would not be a beginner move.

hope it helps
6 0
3 years ago
You want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. to do so, you shoul
nikklg [1K]

If you want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. to do so, you should type chmod a <u>t  <subdir>.</u>

<h3>What is Subdir?</h3>

The Definition of the term subdirectory is known to be a kind of an organizational directory that can be seen on a computer.

It is known to be one that can be found inside another directory  such as a subfolder. It is seen as the file a person is looking for and it is one that needs to have an extension.

Therefore, if you want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. to do so, you should type chmod a <u>t  <subdir>.</u>

Learn more about directory from

brainly.com/question/14845522

#SPJ1

See full question below

You want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. To do so, you should type:

chmod a+_____ <subdir>

- s

- p

- b

- t

6 0
2 years ago
Please don't guess answer for points!!
Irina-Kira [14]

Answer:

The answer is weak, Have a nice day! :)

Explanation:

D) weak

6 0
2 years ago
Read 2 more answers
.............. 1010111 needs to be transferred w.ith odd parity and the answer is
notsponge [240]

Answer:

A. 01010111

Explanation:

This is because in odd parity, the number on the far left (the 8th number) would always be a 0

7 0
2 years ago
Read 2 more answers
What is 9 - 3 ÷ 1/3 + 1 = ?
Ainat [17]
The answer is 9
Hope I helped you
6 0
3 years ago
Read 2 more answers
Other questions:
  • Hi <br> What exactly does this project want from me?thanks for riding
    5·1 answer
  • Match the spreadsheet features with their respective descriptions.
    9·2 answers
  • ________ is the process of translating a task into a series of commands that a computer will use to perform the task.
    5·1 answer
  • What is copy and paste?
    13·2 answers
  • 2.8 Code Practice: Question 2
    11·1 answer
  • Write a program that:
    13·1 answer
  • Which is a good example of kinetic energy
    14·2 answers
  • You will include code that will validate all user input. If the user inputs an invalid value, the program will respond with an e
    14·1 answer
  • it just said i was blocked from brainly for a sec i was like- dang- then i logged in again then it was back to normal uHhHh can
    8·2 answers
  • What is the reason for taking care of design a good computer human interface ​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!