Question: Python Exercise 4 Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that is
Python Exercise 4
Rock Paper Scissors Lizard Spock
Rock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that is
often used to pass time (or sometimes to make decisions.) The rules of the game are outlined
below:
Scissors cuts Paper
Paper covers Rock
Rock crushes Lizard
Lizard poisons Spock
Spock smashes Scissors
Scissors decapitates Lizard
Lizard eats Paper
Paper disproves Spock
Spock vaporizes Rock
Rock crushes Scissors
Write a program that simulates the game of Rock Paper Scissors Lizard Spock!
The user should be able to enter strings for each of their choices (e.g. Rock for Rock,
Paper for Paper etc).
o The code should also ensure that the user only enters the strings Rock, Paper,
Scissors, Lizard or Spock (they should be able to enter upper, lower, title or
alternate versions as long as it correctly spells the proper choice).
Use upper lower or title methods to convert the entry into one format.
This makes it easier to compare choices
Store the possible choices in a list. The computer should randomly select one of the
options from the list using the choice method
The program should then determine the winner using carefully constructed selection
statements
o You can nest if-elif-else within other if-elif-else constructs or you logical
operators to combine conditions statements. Whatever method you choose, be
consistent and thorough!
o Python allows the use of relational operators for strings. Just make sure the case
is consistent
The game should be played as many times as the user wants.
o To craft this, you can use an infinite while loop to start the game (ensuring that
the game will be played at least once) and a break statement to stop playing
o After every game, the program should ask if the user wants to play again. The
user should enter yes or no to stop the game
If yes is entered, a break statement should stop the loop
If no is entered, the game continues
The only acceptable responses are yes and no. If any other responses are
entered, the user should be prompted to enter yes or no (using input
validation). All versions of yes or no (upper, lower, title, etc) should be
accepted.
The program should keep track of:
o The number of games played
o Number of ties
o Number of times the player wins
o Number of times the computer wins
Here is a sample of the solution:
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: towel
That's invalid. Please enter Rock, Paper, Scissors, Lizard or Spock: rock
Computer chose Paper
Paper covers Rock! Computer wins!
Play again? (yes/no): yeah
Invalid response. Play again? Enter yes or no only: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: paper
Computer chose Lizard
Lizard eats Paper! Computer wins!
Play again? (yes/no): yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Scissors
Computer chose Spock
Spock smashes Scissors! Computer wins!
Play again? (yes/no): nah
Invalid response. Play again? Enter yes or no only: no
Number of games played: 0
Games you won: 0
Games the computer won: 3
Tie games: 0
Thanks for playing!
Tip:
This code requires careful planning. Analyze all the possible ways the player or
computer can win and create an outline. (The navigator should take the lead on creating
an outline to ensure that the driver is appropriately guided for this assignment.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
