Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview: The Trivia Challenge Game tests a players knowledge with a series of multiple-choice questions. The game delivers the questions as a single episode. The

Overview: The Trivia Challenge Game tests a players knowledge with a series of multiple-choice questions. The game delivers the questions as a single episode. The episode created as an example is about The Office and is called, The Office. All of the questions relate in some way to The Office. The cool thing about the game is that the questions for an episode are stored in a separate file, independent of the game code. This way, its easy to play different ones. Even better, this means that anyone with a text editor can create their own trivia episode about whatever topic they chooseanything from anime to zoology.

With the basics of files under your belt, its time to tackle the Trivia Challenge game. As youll see in the code, the text file the program reads, trivia.txt, needs to be in the same directory at the program file. To create your own episode full of questions, all you need to do is replace this file with one containing your own work.

Save as: triviaChallengeGame_yourLastName.py

Understanding the Data File Layout

Before we work on the actually game, you should understand exactly how the trivia.txt file is structured.

The very first line of the file is the title of the episode. The rest of the file consists of blocks of eight lines for each question. You can have as many blocks (and thus questions) as you like. Take a look at the text file I posted as an example.

Here is a generic block:

Take a look at the sample

Remember the first line of the file, The Office, is the episode title for this game. The next eight lines are for the first question. The next eight lines are for the second question. So, the line Who Said It? is the category of the first question. The category is just a clever way to introduce the next question. The next line, Who said is the first question in the game. The next four lines are the four possible answers from which the player will choose. So in this case, the correct answer to the question is the forth answer. The next line, Jim was imitating Dwight, explains why the correct answer is correct. The rest of the questions follow the same pattern.

Follow the pseudocode (below) and complete the program.

Requirements:

  • Add you own trivia questions. Minimum of 10. You can choose any topic you like. Must be school appropriate and non-offensive. Hint, your text file should have a total of 81 lines. 1 for the title + 8 for each question * 10 = 81.
  • Your python program should run for any number of questions in the text file (not just 10). It should run until there are no more questions to read in.
  • Work on the python code FIRST. Use my sample trivia file posted in the mean time. Once that is up and running, then develop your 10 trivia questions.
  • You are writing this game (theoretically) for SOMEONE ELSE to play. Therefore, make the interface user-friendly and easy to read.

Sample Pseudocode:

# Trivia Challenge

# triviaChallengeGame.py

# Trivia game that reads a plain text file

# SETTING UP THE GAME

# Open trivia file, get the title of the episode, welcome the player, set score to 0.

# ---insert code below---

# ASKING A QUESTION

# Read the first block of lines for the first question into variables

# Start the main while loop for the game -- will continue to ask questions as long as category

# is not an empty string.

# If category is an empty string the game is over.

# Ask a question by printing the category of the question, the question, and the four possible answers.

# Its important to note that the trivia file does not have numbers next to the possible answer, you

# must figure out how to print them like that in this part of the code.

# ---insert code below---

# GETTING AN ANSWER

# Get the players answer

# ---insert code below---

# CHECKING THE ANSWER

# Compare user answer to correct answer.

# If they match, the player is congratulated and his/her score is increased by one.

# If they don't match, the player is told he/she is wrong.

# In either case, display the explanation.

# Lastly display the players current score.

# ---insert code below---

# GETTING THE NEXT QUESTION

# Get the next block of strings for the next question.

# ---insert code below---

#ENDING THE GAME

#After the loop, close the trivia file and display the player's final score

#---insert code below---

The text file:

Welcome to the BTS Trivia challenge!

Debut

With which of these songs did BTS debut?

No More Dream

Dynamite

Yet to Come

Fire

No More Dream

This is the first song BTS came out with

Production

Does BTS produce their own music?

No

Yes

Maybe

No idea

Yes

All BTS members have produced music before

Nickname

RM stands for:

Rap Monster

Rick & Morty

Role Model

Rift Off

Rap Monster

Rap Monster was inspired by San E's "Rap Genius"

V

Which hand does V uses for writing?

Left

Right

Both (ambidextrous)

None

Both (ambidextrous)

V was born left-handed, but he trained his right hand so that he is equally dominant in both hands

Delivery

_____used to be a delivery boy

Jhope

Jungkook

RM

Suga

Suga

Before joining BTS, Suga worked as a delivery driver

Food

Who is least likely to like spicy food?

Jimin

Suga

Jungkook

J-Hope

Jimin

Jimin said spicy food is too hard to eat

BTS

What does BTS stand for?

Be The Best

Bangtan sonyeondan

Boloron sondega

Bangtan boys

Bangtan sonyeondan

Bangtan sonyeondan translates to Bulletproof Boy Scouts

Piercings

Which band member of BTS ears are not

pierced?

RM

Jin

J Hope

Suga

J Hope

J-Hope is the only member of BTS with no piercings (that we know of), and he seemingly has no plans to get any.

ARMY

ARMY stands for :

Adorable Representative M.C. for Youngsters

Adelaide Representative M.C. for Youth

Adorable Representative M.C. for Youth

Adorable Representative M.C. for You All

Adorable Representative M.C. for Youth

This acronym was created by BTS themselvesFinal Lineup

BTS wasnt even finalized till:

2010

2011

2012

2013

2012

The seven-member band was formed through auditions by Bit Hit Entertainment in 2010 and 2011, and finalized in 2012.

Output:

image text in transcribed
image text in transcribed
Welcome to Trivia Challenge! The Office Who Said It? In "Product Recall" in Season 3. Who said, "Question. What kind of bear is the best?" 1 - Dwight 2 - Phyl11s 3 - Oscar 4 - Jim What's your answer?: 4 Right! Jim was imitating Dwight in this episode. Score: 1 Figurines Who has a Dwight bobble head on their desk? 1 - Dwight 2 - Oscar 3 - Michael 4 - Pam What's your answer?: 3 Wrong. Dwight has a bobble head of himself on his desk. So does Mrs. Franchi. Score: 1 Here Kitty, Kitty Who in the office loves cats? 1-Pam2-Phy11is3-Angela4-Dwight What's your answer?: 3 Right! Angela is obsessed with cats. It seems to be the only thing she's nice to. Score: 2 Name Game Who's the only character that shares his name with the exact name of the actor (full name)? 1-MichaelScott2-CreedBratton3-DwightSehrute4-OgcarMartinez What's your angwer?: 2 Right! Creed Bratton is Creed Bratton but he wag born "William Charles Schneider," Score: 3 That was the last question! Your final score ig: 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions