Skip to the content.

Quiz • 3 min read



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("If you add 1+1, will it equal 2?")
if rsp == "Yes":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("If I ate a whole pi, how much was it? Round to nearest hundredth.")
if rsp == "3.14":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("Can Howie bench a plate? If so how much.")
if rsp == "185 lbs":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
Hello, howienguyen running /bin/python
You will be asked 3 questions.
Question: Are you ready to take a test?
Question: If you add 1+1, will it equal 2?
Yes is correct!
Question: If I ate a whole pi, how much was it? Round to nearest hundredth.
3.14 is correct!
Question: Can Howie bench a plate? If so how much.
185 lbs is correct!
howienguyen you scored 3/3