import getpass, sys
def question_and_answer(prompt):
print("Question: " + prompt)
msg = input()
print("Answer: " + msg)
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_and_answer("Are you ready to take a test?")
rsp = question_with_response("How many siblings do I have?")
if rsp == "1":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What is my favorite school subject?")
if rsp == "English":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What is my favorite color?")
if rsp == "purple":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
Hello, sharonkodali running /Library/Developer/CommandLineTools/usr/bin/python3
You will be asked 3 questions.
Question: Are you ready to take a test?
Answer: yes
Question: How many siblings do I have?
1 is correct!
Question: What is my favorite school subject?
english is incorrect!
Question: What is my favorite color?
purple is correct!
sharonkodali you scored 2/3