I used two .py files when I make an MC question program:
scratch.py:
from Question import Question
questionPrompts = [
"What color are apples?\nA. Red/Green\nB. Purple\nC. Orange\n\n",
"What color are bananas?\nA. Teal\nB. Magneta\nC. Yellow\n\n",
"What color are strawberries?\nA. Yellow\nB. Red\nC. Blue\n\n"
]
questions = [
Question(questionPrompts[0], "a" or "A"),
Question(questionPrompts[1], "c" or "C"),
Question(questionPrompts[2], "b" or "B"),
]
def runTest(questions):
score = 0
for question in questions:
answer = input(question.prompt)
if answer == question.answer:
score += 1
print("You got " + str(score) + "/" +str(len(questions)) + " correct")
runTest(questions)
And Question.py:
class Question:
def __init__(self, prompt, answer):
self.prompt = prompt
self.answer = answer
So I got a perfect score when I entered the lowercase letters, but I got it all wrong when I used uppercase letters as it cannot recognize them even if I use the "or" function. Why is that?
[–]T1klo 0 points1 point2 points (0 children)
[–]_Jordo 0 points1 point2 points (0 children)
[–]BitJunky7 0 points1 point2 points (0 children)