From 8368c858e833709acbd3a9c70e0c43494570bf23 Mon Sep 17 00:00:00 2001 From: gabriel venberg Date: Mon, 22 Feb 2021 13:59:51 -0600 Subject: [PATCH] made quiz generator --- quiz/quiz.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 quiz/quiz.py diff --git a/quiz/quiz.py b/quiz/quiz.py new file mode 100755 index 0000000..0840361 --- /dev/null +++ b/quiz/quiz.py @@ -0,0 +1,33 @@ +#! /usr/bin/env python3 + +#randomquizgenerator creates quizes with questions and awnsers in random order, along with the awnser key. + +import random +import os + +capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix', 'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver', 'Connecticut': 'Hartford', 'Delaware': 'Dover', 'Florida': 'Tallahassee', 'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinois': 'Springfield', 'Indiana': 'Indianapolis', 'Iowa': 'Des Moines', 'Kansas': 'Topeka', 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine': 'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', 'Michigan': 'Lansing', 'Minnesota': 'Saint Paul', 'Mississippi': 'Jackson', 'Missouri': 'Jefferson City', 'Montana': 'Helena', 'Nebraska': 'Lincoln', 'Nevada': 'Carson City', 'New Hampshire': 'Concord', 'New Jersey': 'Trenton', 'New Mexico': 'Santa Fe', 'New York': 'Albany', 'North Carolina': 'Raleigh', 'North Dakota': 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City', 'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhode Island': 'Providence', 'South Carolina': 'Columbia', 'South Dakota': 'Pierre', 'Tennessee': 'Nashville', 'Texas': 'Austin', 'Utah': 'Salt Lake City', 'Vermont': 'Montpelier', 'Virginia': 'Richmond', 'Washington': 'Olympia', 'West Virginia': 'Charleston', 'Wisconsin': 'Madison', 'Wyoming': 'Cheyenne'} + +os.makedirs("./quizes") + +for quizNum in range(35): + quizName = "capitalQuiz"+str(quizNum)+".adoc" + quizFile = open("./quizes/"+quizName, 'w') + + #writing the header. + quizFile.write("= US Captials Quiz\nName:\nDate:\n\n") + + #shuffle order of states + states = list(capitals.keys()) + random.shuffle(states) + + for question in range(len(states)): + rightAnswer = capitals[states[question]] + wrongAnswers = list(capitals.values()) + del wrongAnswers[wrongAnswers.index(rightAnswer)] + answers = random.sample(wrongAnswers, 3) + answers.insert(random.randint(0,3), rightAnswer) + + quizFile.write(". What is the capital of "+states[question]+'\n') + + for i in range(len(answers)): + quizFile.write("\t[ ] "+answers[i]+'\n')