Create a program using Python, following the steps below: 1) Collect the Users name, and store that name. 2) Welcome the user, and ask if that user would like to take the Capitals quiz. 3) Create a dictionary of US states as keys and the state capitals that correspond with your list, as the values (Choose 12 of your favorite states). 4) Then have the program quiz the user, randomly asking for the capital of each of the states in your dictionary. 5) Use a string manipulator, in order to lower case each answer, so the person taking the quiz can upper case if they desire. The comparison and the results will be much better. 6) Have the user be told whether they are right or wrong, and keep track of the results, both right and wrong, in separate counters (variable). 7) Once the user has completed all 12 questions, have the results printed on the screen for the user, and end the program. 8) Ask the user if they would like to take the quiz again. <-- See Below 9) Make the program recursive, so they can take the quiz over and over.
Python code
import random
def quiz():
# states names with capitals in a dictionary
states_dict = {"alabama":"montgomery",
"alaska":"juneau", "california":"sacramento", "hawaii":"honolulu",
"indiana":"indianapolis", "michigan":"lansing",
"mississippi":"jackson", "missouri":"jefferson city","new
york":"albany", "pennsylvania":"harrisburg", "texas":"austin",
"washington":"olympia"}
# get states names by using taking keys of the
dictionary
states = list(states_dict.keys())
# define 2 variables to count correct and wrong
answers
correct = wrong = 0
print("Quiz started\n")
# run loop for 12 times
for i in range(12):
# randomly select a state
state = random.choice(states)
# remove the selected state from
the states list
states.remove(state)
# print the question
number
print("Question",(i+1),"\n")
# print the question
print("What is the capital
of",state)
# read the user answer
answer = input("Enter your
answer\n").lower()
# compare the user answer and
the actual answer
if(states_dict[state] ==
answer):
# increment
correct by 1
correct+=1
else:
# increment
wrong by 1
wrong+=1
print("")
# print no.of correct answers
print("Out of 12 Questions\nNo.of correct
answers:",correct)
# print no.of wrong answers
print("No.of wrong answers:",wrong)
# read user opinion to take the quiz again
opinion = input("Would you like to take capitals quiz
again? yes/no :\n")
if(opinion == "yes" or opinion == "y"):
# call the function
recursively
quiz()
# read user's name and store
username = input("Enter your name :\n")
# print welcome message
print("Hello "+username+"! Welcome to Capitals Quiz")
# read user opinion to take the quiz
opinion = input("\nWould you like to take capitals quiz?
yes/no\n")
if(opinion == "yes" or opinion == "y"):
# call the function quiz()
quiz()
print("Program Ended")
Sample Input/Output



Create a program using Python, following the steps below: 1) Collect the Users name, and store...
Create a program that solves programming exercise below. Within this folder is the file state_capitals.txt. The file is organized with a state name on a line and the next line has its capital. Your program should read this in and create a dictionary from this file. Then use this dictionary to create a quiz, ask the user for 5 random choice states and give the results back at end. Write a program that creates a dictionary containing the U.S. States...
c++ please Create a map that works like a dictionary with words and their definitions. In this case, it will be a set of acronyms, such as HTML, CSS, I/O, etc. Then write a quiz program that prompts the user with an acronym to see if they know what it stands for. Create at least five acronyms and have your program quiz the user for all of them. Have your program display "Right!" if the user is correct, and "No,...
(Java) HELP! Create a program that will ask the user to enter their first name and their favorite number. Ask the user if they would like the information repeated back to them. If they type "Y" display the answers back to them. If they type anything else, display the word "Goodbye". An example of what your output window should look like is below. The system-generated output is in red. The user-provided input is in green. (Your actual program will only...
[PYTHON] Create a chatbot program in Python: a program that appears to talk intelligently to a human using text. Your program should involve asking the user questions and having the computer respond in a reasonably intelligent fashion based on those answers. For example, here is a sample chat: ChatBot: Welcome, I am Chatbot . What is your name? User: My name is Abby . ChatBot: Hello Abby. How old are you? User: 22. <---- Input ChatBot: That is older than...
python 3
Define a function that uses two lists similar to the following to create a dictionary: items = ['laptop', 'tablet', 'smartphone', 'reader', 'camera'] price = [749, 199, 399, 99, 1149] The dictionary should have the names of the items as keys and the prices as values. After creating the dictionary, ask the user to enter the name of an item, and display its price if the item is in the dictionary. If the item is not in the dictionary...
Must be done in python and using linux mint
Write a program to create a text file which contains a sequence of test scores. Each score will be between 0 and 100 inclusive. There will be one value per line, with no additional text in the file. Stop adding information to the file when the user enters -1 The program will first ask for a file name and then the scores. Use a sentinel of -1 to indicate the user...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
CIT 149 Java 1 programming question Use DrJava to compile the following try-catch program ? The Assignment ? Specifications General Structure your file name and class name on the following pattern: The first three letters of your last name (begin with upper case.). Then the first two letters of your first name (begin with upper case.). Follow this with the name of the program: TryCatch. For a student called ’John Doe,’ the class name and file name would be: DoeJoTryCatch...
Please complete the following: Write a Python script to do the following: 1. Ask the use to enter several sentences, one at a time in a loop). To end the sentence entry, the user enters a blank (empty) sentence. 2. Extract each word from each sentence and put it in a list. This will require at least one loop to go through each sentence in the list. It is up to you how you want to get the words in...