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("How many rings did Michael Jordan win in his NBA career?")
if rsp == "6":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("How many teams has Lebron James played for in his lifetime?")
if rsp == "3":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("In what year did the Cavs make a 3-1 comeback in the finals?")
if rsp == "2016":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

print(getpass.getuser() + " you scored " + str(correct) + "/" + str(questions) + " for a score of " + str((correct/questions)*100) + "%" )
Hello, saavangade running /bin/python3
You will be asked 3 questions.
Question: Are you ready to take a test?
Question: How many rings did Michael Jordan win in his NBA career?
6 is correct!
Question: How many teams has Lebron James played for in his lifetime?
3 is correct!
Question: In what year did the Cavs make a 3-1 comeback in the finals?
3 is incorrect!
saavangade you scored 2/3 for a score of 66.66666666666666%

"Notebook Check"

  • toc:true
  • branch: master
  • badges: true
  • comments: true
  • author: Saavan Gade
  • categories: [CSP Assignments, Week 2]