Answer:
Answer is in the attached screenshot.
Explanation:
Using regex to split a given input string via whitespace, then returns the first and last element of the array.
Answer:
A.
Explanation:
The rest is nearly impossible to detect or not worth the time.
Answer:
- import random
-
- states = {
- "Alabama": "Montgomery",
- "California": "Sacramento",
- "Florida": "Tallahassee",
- "Hawaii": "Honolulu",
- "Indiana": "Indianapolis",
- "Michigan": "Lansing",
- "New York": "Albany",
- "Texas" : "Austin",
- "Utah" : "Salt Lake City",
- "Wisconsin": "Madison"
- }
-
- correct = 0
- wrong = 0
- round = 1
- while(round <= 5):
- current_state = random.choice(list(states))
- answer = input("What is the capital of " + current_state + ": ")
-
- if(answer == states[current_state]):
- correct += 1
- else:
- wrong += 1
-
- round += 1
-
- print("Correct answer: " + str(correct))
- 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.
Answer:
Explanation:
If we want to insert the appropriate functions, we can know the operation, for example, it could be a sum, multiply, average or only divide, but if we want to apply for a format number like accounting number, we must go to the tab home and the section number, we can change the format number, an accounting or even text format.