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
kvv77 [185]
3 years ago
10

Write a program that creates a dictionary containing the U.S. states as keys and their capitals as values. (Use the Internet to

get a list of the states and their capitals.) The program should then randomly quiz the user by displaying the name of a state and asking the user to enter that state’s capital. The program should keep a count of the number of correct and incorrect responses. (As an alternative to the U.S. states, the program can use the names of countries and their capitals.)
Computers and Technology
1 answer:
Dima020 [189]3 years ago
7 0

Answer:

  1. import random  
  2. states = {
  3.    "Alabama": "Montgomery",
  4.    "California": "Sacramento",
  5.    "Florida": "Tallahassee",
  6.    "Hawaii": "Honolulu",
  7.    "Indiana": "Indianapolis",
  8.    "Michigan": "Lansing",
  9.    "New York": "Albany",
  10.    "Texas" : "Austin",
  11.    "Utah" : "Salt Lake City",
  12.    "Wisconsin": "Madison"
  13. }
  14. correct = 0
  15. wrong = 0
  16. round = 1
  17. while(round <= 5):
  18.    current_state = random.choice(list(states))
  19.    answer = input("What is the capital of " + current_state + ": ")
  20.    
  21.    if(answer == states[current_state]):
  22.        correct += 1
  23.    else:
  24.        wrong += 1
  25.    
  26.    round += 1
  27. print("Correct answer: " + str(correct))
  28. print("Wrong answer: " + str(wrong))

Explanation:

The solution code is written in Python 3.

Line 3 -14

Create a dictionary of US States with capital as each of their corresponding value. Please note only ten sample states are chosen here.

Line 16 - 18

Create variables to track the number of correct and inaccurate response and also round counter.

Line 19 - 28

Set the while condition to enable user to play the quiz for five questions and use random.choice to randomly pick a state from the dictionary and prompt user to input the capital of selected stated.

If the answer matched with the capital value of the selected state, increment the correct counter by one. Otherwise the wrong counter will be incremented by one. Increment the round counter by one before proceed to next round.

Line 30 - 31

Print the number of correct responses and wrong responses.

You might be interested in
3 thing I learned in ICT
frutty [35]
I’ve learned makes me understand how it is important in our life to have an internet, and also important to know as a things I’ve known. First of all, I have learned about Camtasia, it is a program that are used to make a video about. And to show the others that how to do this or that on the computer.
6 0
3 years ago
___operating space means there is a restriction to the drivers line of sight
Harman [31]

Answer

Closed zone operating space means there is a restriction to the drivers line of sight

Explanation

The line of sight restriction to a driver or while driving is the visible path of travel from your vehicle to your targeted area towards your destination.It is also the area that's visible to a driver while driving.

Closed zone or condition means that there is a restriction to the drivers view or that the space is unavailable in a particular zone.

5 0
3 years ago
Discuss the technologies that implements an infrastructure for component communication
Akimi4 [234]

Explanation:

Consulting and system integration services are relied on for integrating a firm's legacy systems with new technology and infrastructure and providing expertise in implementing new infrastructure along with relevant changes in business processes, training, and software integration. Legacy systems are generally older transaction processing systems created for mainframe computers that continue to be used to avoid the high cost of replacing or redesigning them.

THE IT INFRASTRUCTURE ECOSYSTEM

There are seven major components that must be coordinated to provide the firm with a coherent IT infrastructure. Listed here are major technologies and suppliers for each

4 0
3 years ago
How r u<br> ;)<br> happy what day is it
Ivahew [28]

Answer:

o

dw

Explanation:

5 0
3 years ago
Read 2 more answers
A wireless mesh network with 17 computers would need _______________ connections.
malfutka [58]
Oneeee hundreeeed and thirdy six
4 0
4 years ago
Other questions:
  • discuss in an essay format the steps one needs to take to develop a management information system(MIS)give examples to support y
    7·1 answer
  • __________________ fonts use binary code to define each pixel of the letter to be displayed.
    8·1 answer
  • 1) List at least five smaller behaviors you could break the complex behavior "brushing my teeth" into.
    14·2 answers
  • who will follow me on tiktok and like all my videos? if you do ill give branlist and give u a shoutout and you can enter my big
    15·1 answer
  • The premise of this exam is to synthesize your knowledge and understanding of recursion. Your synthesize may be in the form of a
    14·1 answer
  • Use the drop-down menus to complete the statements about Outlook notes.
    8·1 answer
  • I used the Pearson correlation coefficient for my study to test the correlation and how strong is the relationship between two v
    10·2 answers
  • Line charts are best used for
    15·2 answers
  • Question 3 of 10
    12·1 answer
  • Differentiate between off the shelf software and bespoke software
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!