import random

class Question:
    def __init__(self, text, choices, correct_choice):
        self.text = text
        self.choices = choices
        self.correct_choice = correct_choice

    def check_answer(self, user_answer):
        return user_answer.upper() == self.correct_choice

class Quiz:
    def __init__(self, questions):
        self.questions = questions
        self.score = 0
        random.shuffle(self.questions)

    def run(self):
        for question in self.questions:
            print(question.text)
            self.display_choices(question.choices)

            user_answer = input("Choose your answer (A, B, C, D): ")
            if question.check_answer(user_answer):
                print("Correct answer!")
                self.score += 1
            else:
                print("Wrong answer!")

            print()

        self.display_score()

    def display_choices(self, choices):
        letters = ["A", "B", "C", "D"]
        for i, choice in enumerate(choices):
            print(f"{letters[i]}. {choice}")

    def display_score(self):
        print("Quiz finished!")
        print("Your total score:", self.score)

questions = [
    Question("What is the name of the door through which those who fast will enter on the Day of Resurrection, which is one of the gates of Paradise?", ["Chapter on repentance", "Bab Al-Rayyan", "Chapter of the repentant", "Chapter on jihad"], "B"),
    Question("What is the name of the best night in Ramadan?", ["Last Night ", "First Night", "Night of Destiny", "Friday night"], "C"),
    Question("On which ten days of Ramadan do Muslims expect Laylat al-Qadr?", ["The last ten days", "The first ten days", "Night26", "The middle ten days"], "A")
  ]


quiz = Quiz(questions)
quiz.run()   
            


