Created
June 10, 2017 04:28
-
-
Save johnmboudreaux/a4c600a157af7ffacc4e930fb18a14f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = raw_input("What's your name?") | |
print ("Hi " + name + "!") | |
#set variables | |
answer_dict = {} | |
quiz_dict = {} | |
#quiz answers | |
answer_dict["easy"] = ["Buzz Aldrin", "West Point", "MIT", "astronaut", ""] | |
answer_dict["medium"] = ["Moon rocks", "Apollo", "Soviet Luna", "moon's", ""] | |
answer_dict["hard"] = ["Saturn", "62", "moons", "Titan", ""] | |
answer_holders = ["__1__", "__2__", "__3__", "__4__", ""] | |
#quiz questions | |
quiz_dict["easy"] = answer_holders[0] + " is famously the second human to walk on the moon. When " + answer_holders[0] + " graduated from high school he went on to become third in his class at" + answer_holders[1] + ". They would become a fighter pilot before completing their education in gradute school at " + answer_holders[2] + " before moving on to become an " + answer_holders[3] + "." | |
quiz_dict["medium"] = answer_holders[0] + " on earth come from three sources: those collected by the" + answer_holders[1] + "missions, those collected by the" + answer_holders[2] + "missions and those that were ejected from the" + answer_holders[3] + "surface." + answer_holders[0] + "in the U.S. are considered to be national treasure and are illegal to sell within its borders." | |
quiz_dict["hard"] =answer_holders[0] + " has a total of" + answer_holders[1] + answer_holders[2] + ". The largest is named" + answer_holders[3] + "which is believed to make up 96 percent of the matter orbiting" + answer_holders[0] + "." + answer_holders[3] + "is believed to be one of two" + answer_holders[2] + "its size, but the other one broke up and contributed to creating some of the debris that formed the very distinctive shapes around" + answer_holders[0] + "." | |
#find out user level choice | |
choice = raw_input("welcome to the quiz. you will have 5 chances to get the answers correct. please choose your difficulty level: easy, medium or hard") | |
#use raw data to print level | |
level = choice | |
def get_level(): | |
if choice == "easy": | |
level = "easy" | |
print quiz_dict[level] | |
elif choice == "medium": | |
level = "medium" | |
print quiz_dict[level] | |
elif choice == "hard": | |
level = "hard" | |
print quiz_dict[level] | |
else: | |
level = "easy" | |
print "i did not recognize your choice, defaulting to easy" | |
#should i print here? | |
get_level() | |
#split into a list and replace answer holder | |
def replace_quiz_dict(): | |
if level == "easy": | |
quiz_dict[level] = quiz_dict[level].split() | |
#start the quiz | |
def answering_quiz(): | |
index = 0 | |
failed = 0 | |
right_answers = 0 | |
wrong_answers = 0 | |
for correct_answer in answer_dict[level]: | |
#they are now ansering the next blank | |
answering = 0 | |
while answering == 0 and failed == 0: | |
#get user input for answer | |
answer = raw_input("please fill in the blank for item " + str(index + 1)) | |
#change answer holder | |
answer_holders[index] = correct_answer | |
#execute quiz_dict | |
replace_quiz_dict() | |
#if so see line 54, if not see line 64 | |
if failed == 0 and answer == correct_answer: | |
print "correct!" | |
answering = 1 | |
index += 1 | |
right_answers += 1 | |
if right_answers == 4: | |
print "winner winner chicken dinner. quiz is terminated" | |
else: | |
print "baum baum baum baaaaauuuuummmmm...wrong answer..." | |
wrong_answers += 1 | |
print "you have gotten " + str(wrong_answers) + " answers wrong. you have " + str(5 - wrong_answers) + " tries left." | |
if wrong_answers == 5: | |
print "game over" | |
failed = 1 | |
answering = 1 | |
print answering_quiz() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment