Quiz
import getpass, sys
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
questions = 3
correct = 0
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
question_with_response("Are you ready to take a test?")
rsp = question_with_response("What is several lines of code called?")
if rsp == "sequence":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What does a python file end in?")
if rsp == ".ipynb":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("how do you remove a directory ?")
if rsp == "rmdir":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Did you get everything right?")
if rsp == "yes":
print("Good Job!")
if rsp == "no":
print("Nice try, better luck next time!")
else:
print("rip better luck next time!")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))