Jupyter Notebook
First jupyter post and python quiz
msg = "This is my Jupyter Notebook! :D"
print (msg)
menu = {"burger": 3.99,
"fries": 1.99,
"drink": 0.99}
total = 3.99
print("Menu")
print(menu)
print("Please select an item from the menu")
item = input("Please select an item from the menu")
if item == "burger":
print("Prics is 3.99")
if item == "fries":
print("Price is 1.99")
if item == "drink":
print("Price is 0.99")
if item == "burger and fries":
print("")
import getpass, sys
#create function question_with_response
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
#create variables for questions and number of correct
questions = 6
correct = 0
#create function question_and_answer
def question_and_answer(prompt):
msg = input()
return msg
#start quiz by saying hi to user and asking if they are ready to take the test
print('Hey, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions. Are you ready to take a fun test!? :D Respond with 'ok' to continue.")
question_and_answer("Are you ready to take a fun test!?")
#ask first question
rsp = question_with_response("What command is used to include other functions that are developed?")
#run command if correct add point
if rsp == "import":
print(rsp + " is correct!")
correct += 1
# run else command if incorrect, no point
else:
print(rsp + " is incorrect!")
#ask second question
rsp = question_with_response("What command in this example is used to evaluate a response?")
#run command if correct add point
if rsp == "if":
print(rsp + " is correct!")
correct += 1
#run else command if incorrect, no point
else:
print(rsp + " is incorrect!")
#ask third question
rsp = question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?")
#run command if correct add point
if rsp == "expression":
print(rsp + " is correct!")
correct += 1
# run else command if incorrect, no point
else:
print(rsp + " is incorrect!")
#Introduce what type of questions will be next
print ("The next 3 set of questions will be True or False. Please respond with either capital 'True' or 'False' Good luck and good job so far!")
#ask fourth question
rsp = question_with_response("True or False: The print command outputs the paramater to the terminal.")
#run command if correct add point
if rsp == "True":
print(rsp + " is correct!")
correct += 1
#run else command if incorrect, no point
else:
print(rsp + " is incorrect!")
#ask fifth question
rsp = question_with_response("True or False: Output in Jupyter is below the code cell.")
#run command if correct add point
if rsp == "True":
print(rsp + " is correct!")
correct += 1
#run else command if incorrect, no point
else:
print(rsp + " is incorrect!")
#ask sixth question
rsp = question_with_response("True or False: Static text changes.")
#run command if correct add point
if rsp == "False":
print(rsp + " is correct!")
correct += 1
#run else command if incorrect, no point
else:
print(rsp + " is incorrect!")
# tell user their score
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))