34 lines
2.2 KiB
Python
Executable file
34 lines
2.2 KiB
Python
Executable file
#! /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')
|