In: Physics
I NEED TO CREATE A GUI INTERFACE USING TKINTER CONTAINING : Colors, Image, Button, Title bar, and a Menu bar FOR THE QUESTION BELOW: PLEASE HELP PROGRAMMING LANGUAGE IS PYTHON
Write a simple quiz game that has a list of ten questions and a list of answers to those questions. The game should give the player four randomly selected questions to answer. It should ask the questions one-by-one, and tell the player whether they got the question right or wrong. At the end it should print out how many out of four they got right.
'''Class Based Quiz'''class Question: def __init__(self, prompt, answer): self.prompt = prompt self.answer = answerquestion_prompts = [ "Name the theory given by Albert Einstein?\n(a) 'Gravitational Law'\n(b)'Theory of Relativity'",'\n' "Physics is the study of?\n(a) 'Nature and Natural Phenomena'\n(b)'Chemicals Structures'",'\n' "Which branch of Physics deals with subatomic particles?\n (a) 'Classical Mechanics'\n (b) 'Quantum Mechanics'", '\n' "Photoelectric effect is given by?\n (a) 'Albert Einstein'\n (b) 'Isaac Newton'", '\n' "Which branch deals with Space Science?\n (a) 'Astrophysics'\n (b) 'Quantum Physics'", '\n' ]name = input("Please enter your name: ").title()questions = [ Question(question_prompts[0], "b"), Question(question_prompts[1], "a"), Question(question_prompts[2], "b"), Question(question_prompts[3], "a"), Question(question_prompts[4], "a") ]def run_quiz(questions): score = 0 for question in questions: answer = input(question.prompt) if answer == question.answer: score += 1 print("\n{0}, you scored {1} out of {2}.".format(name, score, len(questions)))run_quiz(questions)
I have created a simple quiz of questions related to physics questions comprising of 5 questions.
You can modify the number and type of Questions and can also increase number of options as per your convenience.
You can use this syntax to create quiz.