Skip to the content.

Quiz! • 3 min read

Description

How much do you know about me?

import getpass, sys
def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg
questions = 3
correct = 0
print('Whats up!, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
question_with_response("Are you ready to take my quiz?")
rsp = question_with_response("How old am I?")
if rsp == "16":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")
rsp = question_with_response("What grade am I in?")
if rsp == "Junior":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")
rsp = question_with_response("How many sisters do I have?")
if rsp == "3":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")
print(getpass.getuser() + " you scored " + str(correct/questions*(100)) +"%")
Whats up!, aidandelgado running /bin/python
You will be asked 3 questions.
Question: Are you ready to take my quiz?
Question: How old am I?
16 is correct!
Question: What grade am I in?
Junior is correct!
Question: How many sisters do I have?
3 is correct!
aidandelgado you scored 100.0%