Python Quiz
A quiz about simple Python commands. Try to get all five questions correct!
import getpass, sys
def question_with_response(prompt):
print(prompt)
msg = input()
print("You said: " + msg + ".")
return msg
questions = 5
correct = 0
print("Hello! Welcome to Drew's super awesome (slightly plagiar-inspired) Python quiz!")
print("You will be asked " + str(questions) + " questions about basic Python commands. All quiz responses should be in all lowercase letters.")
print("Before we begin, what would you like me to call you?")
bigboy = input()
print(bigboy + "? That's a cool name!")
rsp = question_with_response("1. Let's start with the simplest function of all: how can you make Python display static text?")
if rsp == "print":
print("That's right! Let's make things more interesting.")
correct += 1
else:
print("Not quite... The response we were looking for was 'print'.")
rsp = question_with_response("2. When using the 'if' function to force a unique reaction for a specific scenario, which function lets you give a different response for ALL other answers?")
if rsp == "else":
print("Good job! Let's continue...")
correct += 1
else:
print("Nope... Looks like you'll have to try something ELSE for that one.")
rsp = question_with_response("3. This three-letter function can redefine a phrase to automate certain behaviors when used. What is it?")
if rsp == "def":
print("Great job! Two more to go.")
correct += 1
else:
print("That's DEF-initely not it...")
print("Let's see how you're doing so far, " + bigboy + "...")
if correct == 3:
print("Wow! 3/3! You're a natural. Let's get back to it.")
elif correct == 2:
print("2/3 isn't bad, you know. Get the next two right and you'll have a solid B minus!")
elif correct == 1:
print("1/3 isn't quite ideal, but it's better than nothing. Why not give these next two your best shot?")
else:
print("Really? None? ...I mean, you've got two more chances to get some points on the board...")
rsp = question_with_response("4. Which function allows the user to provide a custom response to a given prompt?")
if rsp == "input":
print("That's right! You've been using that the whole time, FYI.")
correct += 1
else:
print("Unfortunately, you seem to have INPUT an incorrect response.")
rsp = question_with_response("5. The home stretch! To display a variable, for example, in printed static text, which symbol separates the variable from the rest of the quote?")
if rsp == "+":
print("Nailed it!")
correct += 1
elif rsp == "plus":
print("Nailed it!")
correct += 1
else:
print("Rough conclusion...definitely not a PLUS.")
per_score = (correct / questions) * 100
print(bigboy + ", you scored " + str(correct) +"/" + str(questions) + "! That's " + str(per_score) + "%.")
if correct < 4:
print("Too bad, though! You needed at least 4 out of 5 (80.0" + "%" + ") of the problems correct to pass. Why not reload and try again?")
elif correct == 4:
print("One mistake is perfectly okay! You still managed to pass this quiz. Congratulations!")
else:
print("You managed to pass with flying colors! A perfect score! Why didn't you make this quiz, then?")
if bigboy == "Drew" and correct == 5:
print("Whadduya mean you did make this? You're THAT Drew? What a coincidence.")
elif bigboy == "drew":
print("Whadduya mean you did make this? You're THAT Drew? What a coincidence.")