Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have the following code to write for classwork. It is python programming. The syntax seems to be wrong, can you please fix it. Thank

I have the following code to write for classwork. It is python programming. The syntax seems to be wrong, can you please fix it. Thank you.

import random class Question: def __init__self(self, question, answer1, answer2, answer3, answer4, correct_answer): self.__question = question self.__answer1 = answer1 self.__answer2 = answer2 self.__answer3 = answer3 self.__answer4 = answer4 self.__correct_answer = correct_answer def get_question(self): return self.__question def get_answer1(self): return self.__answer1 def get_answer2(self): return self.__answer2 def get_answer3(self): return self.__answer3 def get_answer4(self): return self.__answer4 def get_correct_answer(self): return self.__correct_answer def main(): # copy and paste questions from file  list_questions = [Question("What famous document begins: When in the course of human events...?",\ "1: The Gettysburg Address","2: The US Declaration of Independence","3: The Magna Carta","4: The US Bill of Rights",2),\ Question("(2) Who said A billion dollars isn't worth what it used to be?","1: J. Paul Getty","2: Bill Gates",\ "Warren Buffet","Henry Ford",1),Question("(3) What number does giga stand for?","1: One thousand","2: One million",\ "3: One billion","4: One trillion",3),Question("(4) What number is 1 followed by 100 zeros?","1: A quintillion",\ "2: A googol","3: A moogle","4: A septaquintillion",2),Question("(5) Which of the planets is closest in size to our moon?",\ "1: Mercury","2: Venus","3: Mars", "4:Jupiter",1),\ Question("(6) What do you call a group of geese on the ground?","1: skein", "2: pack","3: huddle","4:gaggle",4),Question("(7) What do you call a group of geese in the air?",\ "1: skein", "2: pack","3: huddle","4: gaggle",1),Question("(8) Talk show host Jerry Springer was the mayor of this city.",\ "1: Chicago","2: Indianapolis","3: Cincinnati","4: Houston",3),Question("(9) On a standard telephone keypad, the letters T, U, and V are matched to what number?",\ "1: 5","2: 6","3: 7","4: 8",4),Question("(10) Crickets hear through this part of their bodies.","1: Head",\ "2:Knees","3:Ears","4:Tail",2)] ####  correct_answer1= 0 questions_attempted= [] i=1 while i <=5: number= random.randint(0,9) if number not in questions_attempted: print("Question",i) print(list_questions[number].get_question()) print(list_questions[number].get_answer1()) print(list_questions[number].get_answer2()) print(list_questions[number].get_answer3()) print(list_questions[number].get_answer4()) answer= input("Enter the answer, please: ") if list_questions[number].get_correct_answer()== int(answer): print("It is correct") else: print("It is incorrect") i += 1 print ("It is player 2's turn") i=1 correct_answer2= 0 while i <= 5: number = random.randint(0, 9) if number not in questions_attempted: print("Question", i) print(list_questions[number].get_question()) print(list_questions[number].get_answer1()) print(list_questions[number].get_answer2()) print(list_questions[number].get_answer3()) print(list_questions[number].get_answer4()) answer = input("Enter the answer, please: ") if list_questions[number].get_correct_answer() == int(answer): print("It is correct") else: print("It is incorrect") number= random.randint(0,9) if number not in questions_attempted: print("Question", i) print(list_questions[number].get_answer1()) print(list_questions[number].get_answer2()) print(list_questions[number].get_answer3()) print(list_questions[number].get_answer4()) answer = input("Enter the answer, please: ") if list_questions[number].get_correct_answer() == int(answer): print("It is correct") else: print("It is incorrect") print( "The scores are:") print("Player 1 has", correct_answer1, "correct") print("Player 2 has", correct_answer2, "correct") if correct_answer1> correct_answer2: print("Player 1 wins") elif correct_answer2> correct_answer1: print("Player 2 wins") else: print("It is a tie") main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

Stages of a Relationship?

Answered: 1 week ago