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 command is used to change the directory?")
if rsp == "cd":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What command is used to open the list computer file?")
if rsp == "ls":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is wrong!")
rsp = question_with_response("What file type do you make a notebook?")
if rsp == ".ipynb":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is wrong!")
rsp = question_with_response("Did you have fun?")
if rsp == "yes":
print("Good!")
if rsp == "no":
print("Well that's too bad!")
else:
print("oh")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))