Quiz Brain
The QuizBrain, as the name suggests, is the brain of the application. Let's create quiz_brain.py file and add the following code there:
The first method has_more_questions() checks whether the quiz has more questions or not. The next method next_question() gets the question from the questions list at index question_no and then increments the question_no attribute returns a formatted question. The check_answer() method takes user_answer as an argument and checks whether the user's answer is correct or not. It also maintains the score and returns boolean values. The last method get_score() returns the number of correct answers, wrong answers, and score percentage.
3
