I have been working on a program that I saw on a tutorial that creates Multiple choice test.
I created a class named Question.
Code for Question:
Rest of Code:
I created a class named Question.
Code for Question:
class Question:
def _init_(self, prompt, answer):
self.prompt = prompt
self.answer = answerThe rest of my code is another fileRest of Code:
from Question import Question
question_prompts = [
"What kind of vessel is the Japanese Soryu Class?\n(a) Submarine\n(b) Frigate\n(c) Destroyer\n(d) Cruiser\n\n",
"What is the primary anti-ship weapon of the US Navy?\n(a) SM2\n(b) SM6\n(c) Sea_Sparrow\n(d) Harpoon\n\n",
"Name of the new destroyer class in the Chinese PLA Navy?\n(a) Type_45\n(b) Type_52C\n(c) Type_55\n(d) Type_23\n\n"
]
questions = (
Question(question_prompts[0], "a"),
Question(question_prompts[1], "d"),
Question(question_prompts[2], "c"),
)
def run_test(questions):
score = 0
for question in questions:
answer = input(question.prompt)
if answer == question.answer:
score += 1
print("You got " + str(score) + "/" + str(len(question)) + "correct ")
run_test(questions)When I run the code the following error is createdError:Traceback (most recent call last):
File "C:/Users/johne/PycharmProjects/untitled/Multiple choice quiz.py", line 9, in <module>
Question(question_prompts[0], "a"),
TypeError: Question() takes no argumentsI am unsure of what the issue is with the arguments. Any help would be greatly appreciated
