import getpass, sys
questions = 3
correct = 0
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
def is_correct(response,answer):
global correct
if response == answer:
print(response + " is correct!")
correct+=1
return correct
else:
print (response + " is incorrect")
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 command is used to include other functions that were previously developed?")
is_correct(rsp,"import")
rsp = question_with_response("What command is used to evaluate correct or incorrect response in this example?")
is_correct(rsp,"if")
rsp = question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?")
is_correct(rsp,"expression")
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
Quiz • 2 min read
Description
Linux shell/bash quiz with new function