Hand in by emalling -py file to neil Simonetti@brynathyn.edu Create a python pro
ID: 3595693 • Letter: H
Question
Hand in by emalling -py file to neil Simonetti@brynathyn.edu Create a python program that asks the user to take a short quiz that provides the user with feedback and a statement. The project should have at least five questions (more questions can raise the content portion of the grade, see next page). Base project: The five (or more) questions are trivia questions with answers to be typed at a prompt (the questions can be multiple choice, where the expected answer is a number or letter, to avoid worrying about upper vs. lower case, numbers can be used.) Example: What is the capital of Pennsylvania? (1) Philadelphia (2) Bryn Athyn (3) Harrisburg (4) Pittsburgh Enter your answer (1-4): After the user has answered all the questions, a function should be used (with a parameter indicating the number of correct answers) to print a message for each potential number of correct answers. (some messages may be the same, but there should be at least three different messages possible) ExampleExplanation / Answer
for quizNum in range(35):
quizFile = open('capitalsquiz%s.txt' % (quizNum + 1), 'w')
answerKeyFile = open('capitalsquiz_answers%s.txt' % (quizNum + 1), 'w')
quizFile.write('Name: Date: Period: ')
quizFile.write((' ' * 20) + 'State Capitals Quiz (Form %s)' % (quizNum + 1))
quizFile.write(' ')
states = list(capitals.keys())
random.shuffle(states)
# TODO: Loop through all 50 states, making a question for each.
quizFile.write('%s. What is the capital of %s? ' % (questionNum + 1,
states[questionNum]))
for i in range(4):
quizFile.write(' %s. %s ' % ('ABCD'[i], answerOptions[i]))
quizFile.write(' ')
answerKeyFile.write('%s. %s ' % (questionNum + 1, 'ABCD'[
answerOptions.index(correctAnswer)]))
quizFile.close()
answerKeyFile.close()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.