Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this lab, you are to build a trivia game by using Python Language. The game should present each question either in order or randomly
In this lab, you are to build a trivia game by using Python Language. The game should present each question either in order or randomly to the player, and display up to four possible answers. The player is to input what they believe to be the correct answer. The game will tell the player if they got it right or wrong and will display their score. If they got it right, their score will go up If they got it wrong, their score will stay the same. After all the questions have been asked, the game will present the final score correct, the final score incorrect and allow the player to play again if they choose. You have a lot of leeway in designing this game and you can use your book though there are minimum requirements to obtain all points mentioned after this paragraph Develop your own code and try to use as many of these tools and techniques that you learned about in Chapters in your text. You may leverage other techniques in other Chapters that were not covered if you like, BUT you will need to add comments to the code with why you selected them and a brief description on how it works.
This final script MUST include the following at a minimum:
Main line logic Error handling Tryexceptelsefinal Header Comments Globallocal Variables Users name, counters, etc. At least custom function Use of ListTupleDictionary Use of at least looping function while for
To get started, here are five, fouranswer multiple choice questions that you can use. The correct answers have been denoted with an asterisk. You may use your own questions if you like. When you load the questions into your program, you may rewrite them however you need to How many computergenerated effects were used in the movie Lord of the Rings Return of the King? In the movie "The Blues Brothers", what does Jake order at the diner? A medium pizza with pineapple and ham cheeseburgers with the works and a tall glass of milk fried chickens and a Coke A small Greek salad with extra feta, a steak well done baked potatoes, and a coffee In The Simpsons, what football team has Homer always wanted to own? Washington Redskins Dallas Cowboys Denver Broncos Cleveland Browns In the TV show Seinfeld, what did Elaine decide was 'her song'? I am Woman Desperado Yesterday Witchy Woman Babe Ruth debuted in professional baseball at the age of years old with which team? Boston Red Sox New York Yankees St Louis Browns Cincinnati Reds
My Code: When I run it showing Invalid Syntax. Please help me fix it asap. Thanks
import random
import time
def main:
try:
# Start the game
welcome # Display welcome message
game # Start the game
playagain # Ask if the player wants to play again
except:
printAn error occurred."
def welcome:
Display a welcome message and instructions to the player.
printWelcome to the trivia game!"
printYou will be presented with multiplechoice questions."
printPlease input the number corresponding to your answer."
print
def game:
Present questions to the player, get their answers, and update scores.
# Define questions and their corresponding answers
questions
"How many computergenerated effects were used in the movie Lord of the Rings Return of the King?":
"answers": : : : :
"correct":
In the movie 'The Blues Brothers', what does Jake order at the diner?":
"answers": : "A medium pizza with pineapple and ham", : cheeseburgers with the works and a tall glass of milk", : fried chickens and a Coke", : "A small Greek salad with extra feta, a steak, baked potatoes, and a coffee"
"correct":
In The Simpsons, what football team has Homer always wanted to own?":
"answers": : "Washington Redskins", : "Dallas Cowboys", : "Denver Broncos", : "Cleveland Browns"
"correct":
In the TV show Seinfeld, what did Elaine decide was 'her song'?":
"answers": : "I am Woman", : "Desperado", : "Yesterday", : "Witchy Woman"
"correct":
"Babe Ruth debuted in professional baseball at the age of years old with which team?":
"answers": : "Boston Red Sox", : "New York Yankees", : St Louis Browns", : "Cincinnati Reds"
"correct":
scorecorrect # Counter for correct answers
scoreincorrect # Counter for incorrect answers
# Shuffle questions
questionslist listquestionskeys
random.shufflequestionslist
for question in questionslist:
printquestion
answers questions
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