Question: Instructions: This program should be done traditionally (not in a Jupyter notebook). You are to design a state capital quiz. Each line in the file

Instructions:

  • This program should be done traditionally (not in a Jupyter notebook).
  • You are to design a state capital quiz.
  • Each line in the file should be formatted as a state and its capital.
  • Your program should ask 10 random questions and output the number of correct answers.
  • You should have at least three functions in your program.
  • You MUST upload all files needed to run your code. This could be:
    • the data file (states/capitals) [must have]
    • the main program [must have]
    • a library of functions [optional]
  • Put all files into a folder and compress them [Mac: right click and go to Compress/Windows: right click Send to >> Zipped file].

This is what I have so far but I'm stuck.

{

"version": "0.2.0",

"configurations": [

{

"name": "Python: Current File",

"type": "python",

"request": "launch",

"program": "${file}",

"console": "integratedTerminal",

"cwd": "${jupyternotebookassignments}/${ch1programs}"

}

]

}

import random

def main():

with open('ch1programs\data.txt', 'r') as document:

dataDict = {}

for line in document:

if line.strip():

key, value = line.split(" = ")

dataDict[key] = value

def question(key, value):

key = dataDict.keys()

value = dataDict.value()

print("What is the Capital of {value}?")

answer = input("What is your answer:")

if answer != key:

points += 0

print ("Ooops wrong answer, maybe next time")

if answer == dataDict[key]:

points += 1

print ("That is correct")

document.close()

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!