Amay's Python Vocab Quiz
Python Hacks
import getpass, sys
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
# defining q and c as question and correct answer
q = 6
c = 0
# setting up the of the questions
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(q) + " questions.")
question_and_answer("Are you ready to take a test?")
# asking 6 question
rsp = question_with_response("What command is used to include other functions that were previously developed?")
if rsp == "import":
print(rsp + " is correct!")
c += 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!")
c += 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!")
c += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What is another word for putting data into you computer?")
if rsp == "input":
print(rsp+ " is correct!")
c += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("If you see several lines of code in order, what is it known as?")
if rsp == "sequence":
print(rsp + " is correct!")
c += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What is a Print Working Directory known as?")
if rsp == "pwd":
print(rsp + " is correct!")
c += 1
else:
print(rsp + " is incorrect!")
# creating ratio/percentages between c and q
print(getpass.getuser() + " you scored " + str(c) +"/" + str(q))
y = c/q
x = int (100*y)
print("Or " + str(x) + "%")