Question
I have a question to the Who Wants to be a Millionaire game in python. How to show the users point total after each question?
I have a question to the "Who Wants to be a Millionaire game in python. How to show the users point total after each question? Here's what I have done so far...
def main(): #display intro print("Let's Play 'Computer Trivia Game'!") points = totalpoints = 0 #prompt for menu choice print ("Please choose from the following menu: ") def question1(): ans = '' print("1.Which computer company was named after the founder's memories of a summer in an Orchard?") print("a. Banana b. Apple c. Pineapple d. Avocado") ans = input("Answer: ") #validate ans if ans == 'b': print("Correct Answer, you earn 100 points ", totalpoints) return totalpoints else: print("Wrong Answer, you earn no points this time ") return 0 def question2(): ans = '' print("2.Who is the father of the computer?") print("a. Charles Babbage b. Charles Chapplin c. Al Gore d. Barack Obama") ans = input("Answer: ") if ans == 'a': print("Correct Answer, you earn 200 points. Your total points is ", totalpoints) return totalpoints else: print("Wrong Answer, you earn no points this time ") return 200
def question3(): ans = '' print("3.Who invented the electromechanical machine called the Bombe, which was designed to break Enigma faster?") print("a. never invented b. Charles Babbage c. Donald Trump d. Alan Turing") ans = input("Answer: ") if ans == 'd': print("Correct Answer, you earn 500 points ", totalpoints) return 500 else: print("Wrong Answer, you earn no points this time ") return 500
def question4(): ans = '' print("4.What was the name of the computer language named after a French philosopher and mathematician?") print("a. PYTHON b. JAVA c. PASCAL d. RUBY") ans = input("Answer: ") if ans == 'c': print("Correct Answer, you earn 1000 points ", totalpoints) return 1000 else: print("Wrong Answer, you earn no points this time ") return 1000
def question5(): ans = '' print("5. What company invented floppy disc?") print("a. Apple b. Microsoft c. IBM d. HP") ans = input("Answer: ") if ans == 'c': print("Correct Answer, you earn 2000 points ", totalpoints) return 2000 else: print("Wrong Answer, you earn no points this time ") return 2000
def game(): points = 0 points += question1() points += question2() points += question3() points += question4() points += question5()
totalpoints = 0 totalpoints = points + 100 totalpoints = points + 200 totalpoints = points + 500 totalpoints = points + 1000 totalpoints = points + 2000 print("Your total points is ",points)
if __name__ == '__main__': while True: #display menu print("1) See Rules 2) Play Game 3) Quit ") #prompt for menuChoice choice = int(input("Enter choice: ")) if choice == 1: print("Each question, if answered correctly, will have a point value attached to it. The point values should be as follows: 100, 200, 500, 1000, 2000.") elif choice == 2: game() else: print("Game Over! Thanks for playing The Computer Trivia Game!") exit(1) main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started