import getpass, sys
def question_and_answer(prompt):
print("Question: " + prompt)
msg = input()
print("Answer: " + msg)
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
questions = 5
correct = 0
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
question_and_answer("Are you ready to take a test?")
rsp = question_with_response("What command is used to include other functions that were previously developed?")
if rsp == "import":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What command is used to evaluate correct or incorrect response in this example?")
if rsp == "if":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?")
if rsp == "expression":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Which command is the opposite of if?")
if rsp == "else":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is not correct!")
rsp = question_with_response("What are we using to run the ipynb files?")
if rsp == "Jupyter Notebook":
print(rsp + " is correct!")
correct +=1
else:
print(rsp + " is not correct!")
score = ((correct*100)/questions)
print(type(questions))
print (str(score) + "% This is your percentage")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
print(type(questions))
Quiz • 4 min read
Description
A quiz about the things we learned in computer science.