NBA Trivia
A tutorial of fastpages for Jupyter notebooks.
print("Rules: There will be a total of 10 questions starting very easy and finishing very difficult. Good luck!")
import getpass, sys
#This is a function where it acts the user a question based on what the prompt is regarding NBA Trivia
def question_and_answer(prompt):
print("Question: " + prompt)
msg = input()
print("Answer: " + msg)
# This is where the user will answer their question based on the give information through the prompt variable
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
# There are four questions in quiz and you start with zero correct and gain more as the user answers questions correctly
questions = 4
correct = 0
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
question_and_answer("Ready for this NBA Quiz?")
rsp = question_with_response("Who won the 2022 NBA Championship")
if rsp == "Golden State Warriors":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Who has the most rings in NBA History?")
if rsp == "Bill Russell":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What notable NBA player believes the Earth is flat?")
if rsp == "Kyrie Irving":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Who scored the most points in a NBA game?")
if rsp == "Wilt Chamberlain":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
![]({{ site.baseurl }}/images/proof.png "fast.ai's logo")