made quiz generator
This commit is contained in:
		
							parent
							
								
									828aaaee0a
								
							
						
					
					
						commit
						8368c858e8
					
				
					 1 changed files with 33 additions and 0 deletions
				
			
		
							
								
								
									
										33
									
								
								quiz/quiz.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								quiz/quiz.py
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -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')
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue