, , , ,

[SOLVED] Python exercise 8 trivia game

$25

File Name: Python_exercise_8_trivia_game.zip
File Size: 273.18 KB

5/5 - (1 vote)

Trivia Game – Questions Class (15 pts)
Trivia Questions (20 pts)
Driver Program (25 pts)
For this assignment, you will create three modules that are all related. Instructions for each
module are outlined below:
Questions Class (15 pts)
Define a class that has the following attributes:
• A trivia question
• Answer 1
• Answer 2
• Answer 3
• Answer 4
• The number for the correct answer (1, 2, 3 or 4)
The class must have an __init__ method, but you can create additional accessors, mutators or a
__str__ method as needed.
This module should only contain the class definition (with the appropriate methods for each
attributes). Don’t forget to run this module to check for errors! (Note: output should not be
expected here.)
Trivia Questions (20 pts)
Define a function in this module that creates a list of trivia question objects. This module should
import the module that contains the class definition for the questions. The function doesn’t
require any parameters but should return a list of question objects.
The returned list MUST contain at least 10 questions. (You are welcome to change the
questions provided in the sample, or add additional questions, as long as the total number of
questions are even.)
Note: This module should only contain the function definition that generates the list of
questions. (No class definition is needed in this module.) Don’t forget to run this module to
check for errors! (Note: output should not be expected here either.)
Driver Program (25 pts)
Write a program that executes the trivia game based on the list of trivia questions! The game
should be played in the following manner:
• This game is played with two players. Starting with player 1, each player gets a turn of
answering (at least) 5 trivia questions. (At least 10 questions is required.)
• Each question should be displayed along with 4 possible answers. (Only one of the
answers should be correct.)
• The player enters a value 1, 2, 3 or 4 corresponding to their selected answer.
• If the player’s answer is correct, that player gets a point.
• After all answers have been selected for all of the questions, the program displays the
number of points earned by each player and declares a tie or the player with the highest
points as the winner.
This module should import the module used to generate and return a list of trivia questions.
A sample output is shown below. (Remember – You are allowed to change the questions or to
add additional questions, but there must be at least 10, and the total number of questions must
be even.)
Sample output:
Question for the first player:
How many days are in a lunar year?
1. 354
2. 365
3. 243
4. 379
Enter your solution (a number between 1 and 4): 2
That is incorrect. The correct answer is 1
Question for the second player:
What is the largest planet?
1. Mars
2. Jupiter
3. Earth
4. Pluto
Enter your solution (a number between 1 and 4): 2
That is the correct answer.
Question for the first player:
What is the largest kind of whale?
1. Orca whale
2. Humpback whale
3. Beluga whale
4. Blue whale
Enter your solution (a number between 1 and 4): 1
That is incorrect. The correct answer is 4
Question for the second player:
Which dinosaur could fly?
1. Triceratops
2. Tyrannosaurus Rex
3. Pteranodon
4. Diplodocus
Enter your solution (a number between 1 and 4): 3
That is the correct answer.
Question for the first player:
Which of these Winnie the Pooh characters is a donkey?
1. Pooh
2. Eeyore
3. Piglet
4. Kanga
Enter your solution (a number between 1 and 4): 2
That is the correct answer.
Question for the second player:
What is the hottest planet?
1. Mars
2. Pluto
3. Earth
4. Venus
Enter your solution (a number between 1 and 4): 4
That is the correct answer.
Question for the first player:
Which dinosaur had the largest brain compared to body size?
1. Troodon
2. Stegosaurus
3. Ichthyosaurus
4. Gigantoraptor
Enter your solution (a number between 1 and 4): 4
That is incorrect. The correct answer is 1
Question for the second player:
What is the largest type of penguins?
1. Chinstrap penguins
2. Macaroni penguins
3. Emperor penguins
4. White-flippered penguins
Enter your solution (a number between 1 and 4): 3
That is the correct answer.
Question for the first player:
Which children’s story character is a monkey?
1. Winnie the Pooh
2. Curious George
3. Horton
4. Goofy
Enter your solution (a number between 1 and 4): 2
That is the correct answer.
Question for the second player:
How long is a year on Mars?
1. 550 Earth days
2. 498 Earth days
3. 126 Earth days
4. 687 Earth days
Enter your solution (a number between 1 and 4): 1
That is incorrect. The correct answer is 4
The first player earned 2 points.
The second player earned 4 points.
The second player wins the game.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Python exercise 8 trivia game[SOLVED] Python exercise 8 trivia game
$25