QandA = [
"1. True or False, Def is a key word in Python that defines a function", "True",
"2. True or False, In Python anatomy of you will NOT be importing libraries and functions?", "False",
"3. True or False, Hello world is a string literal?", "True",
"4. True or False,?", "Answer",
"5. True or False, Input and Output in Jupyter Notebook Input is NOT in line with Output?", "True",
"6. True or False, an if expression is not evaluated for true or false", "False",
"7. True or False, return command in function does not return msg input by user", "False",
"8. True or False, false takes branch of code directly under else command", "True",
"9. True or False, correct += 1 is NOT the way to add one to the score", "False",
"10. True or False,?", "Answer",
]
#total points and using new quiz var
points = 0
current = 0
quiz = 1
print ("Welcome to my true or false quiz!")
#Using while lets me loop function
while quiz < 11:
question = input (QandA[current])
if question == QandA[current+1]:
print ("That's correct!")
points = points +1
current = current +2
else:
print ("Sorry, that is incorrect!")
points = points -1
current = current -2
quiz = quiz +1
#Final Message
print ("You got " + str(current) + "/" + str(len(QandA)) + " correct")
score = 0
# Question 1
answer1 = input("What does Def do in a function? \na. nothing \nb. defines a function \nc. sudo code \nd. changes directory \nAnswer: ")
if answer1 == "b" or answer1 == "defines a function":
score += 1
print ("correct!")
print ("score: ", score)
print ("\n")
else:
print("Incorrect! The answer is: defines a function.")
print("score: ", score)
print("\n")
# Question 2
answer2 = input("What is Python3 \na. A type of snake \nb. A programming language \nc. A google game \nd. Javascript \nAnswer: ")
if answer2 == "b" or answer1 == "A programming language":
score += 1
print ("correct!")
print ("score: ", score)
print ("\n")
else:
print("Incorrect! The answer is: A programming language")
print("score: ", score)
print("\n")
# Question 3
answer3 = input("What is a sequence? \na. Two or more lines of code \nb. A line of code \nc. multiple words \nd. I dont know \nAnswer: ")
if answer3 == "a" or answer1 == "Two or more lines of code":
score += 1
print ("correct!")
print ("score: ", score)
print ("\n")
else:
print("Incorrect! The answer is: Two or more lines of code")
print("score: ", score)
print("\n")
#Final Message
if score <= 1:
print ("Your total score is:", score, "- That's OK")
elif score == 2:
print ("Your total score is:", score, "- Nice Job")
else:
print ("Your total score is:", score, "-AMAZING!")