toc: true layout: post description: Ethan's Python Quiz questions categories: [markdown]

Python Quiz

Python Quiz

A display of the Python Quiz

import getpass, sys

def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg

questions = 4
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 does the NBA stand for?")
if rsp == "National Basketball Association":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("What team has the theme color of Purple and Yellow?")
if rsp == "Lakers":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("Who is the best player on the Lakers?")
if rsp == "Lebron James":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("What is the line on the side of the court called?'")
if rsp == "Sideline":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")  

rsp = question_with_response("What do you shoot when you get fouled?'")
if rsp == "Free Throws":
    print(rsp + " is correct!")
    correct += 1
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
Hello, Ethan2806 running c:\Users\Ethan2806\anaconda3 2\python.exe
You will be asked 4 questions.
Question: Are you ready to take a test?
Question: What team has the theme color of Purple and Yellow?
Lakers is correct!
Question: Who is the best player on the Lakers?
Lebron James is correct!
Question: What is the line on the side of the court called?
Sideline is correct!
Question: What do you shoot when you get fouled?
Free Throws is correct!
Ethan2806 you scored 4/4