Python
After reading through the Python IO article, I created this article to start testing, messing around, and using both python and Jupyter Notebooks. Below is the quiz provided and edits made based on hacks at the bottom of the article.
import getpass, sys
import math
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
questions = ["What command is used to include other functions that were previously developed?", "What command is used to evaluate correct or incorrect response in this example?", "Each 'if' command contains an '_________' to determine a true or false condition?"]
num_q = len(questions)
answers = ["import", "if", "expression"]
correct = 0
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(num_q) + " questions.")
for question in questions:
rsp = question_with_response(question)
if rsp == answers[questions.index(question)]:
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
print(getpass.getuser() + " you scored " + str(correct) + "/" + str(num_q) + ", or " + str(math.floor(correct / num_q * 10000) / 100) + "%!")
Hello, iwu88 running /bin/python
You will be asked 3 questions.
Question: What command is used to include other functions that were previously developed?
import is correct!
Question: What command is used to evaluate correct or incorrect response in this example?
else is incorrect!
Question: Each 'if' command contains an '_________' to determine a true or false condition?
expression is correct!
iwu88 you scored 2/3, or 66.66%!