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 Ashwin's favorite programing language?")
if rsp == "python":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What is Ashwin's favorite school subject?")
if rsp == "math":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What is Ashwin's favorite tv show?")
if rsp == "better call saul":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
if int(correct)/int(questions) == 1:
print("Great Job")
else:
print("Better Luck next time")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
Hello, kasm-user running /bin/python
You will be asked 3 questions.
Question: Are you ready to take a test?
Question: What is Ashwin's favorite programing language?
no is incorrect!
Question: What is Ashwin's favorite school subject?
no is incorrect!
Question: What is Ashwin's favorite tv show?
no is incorrect!
Better Luck next time
kasm-user you scored 0/3