Question

5.12 A5 Program Do you want to play. a. game? The Big Bang Theory fans may recognize Rock Paper Scissors Lizard Spock as a gaThe rules: • Scissors cuts Paper • Paper covers Rock • Rock crushes Lizard • Lizard poisons Spock • Spock smashes Scissors •LAB ACTIVITY 5.12.1: A5 Program 0/10 main.py Load default template. from random import choice, seed choices = [rock, paper54 def main(): human=human_player() computer =computer_player() print(human, outcome (human, computer), computer) 59 if __nam

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here, I have updated the outcome function with a couple of missing cases out of the 10 rules. Rules are mentioned as comments along the code for readability.

Code:

def outcome(player1, player2):
   if player1 == choices[2] and player2 == choices[1]: # Scissor cuts Paper
       return 'win'
   elif player1 == choices[1] and player2 == choices[0]: # Paper covers Rock
       return 'win'
   elif player1 == choices[0] and player2 == choices[3]: # Rock crushes Lizard
       return 'win'
   elif player1 == choices[3] and player2 == choices[4]: # Lizard poisons Spock
       return 'win'
   elif player1 == choices[4] and player2 == choices[2]: # Spock smashes Scissors
       return 'win'
   elif player1 == choices[2] and player2 == choices[3]: # Scissors decapitates Lizard
       return 'win'
   elif player1 == choices[3] and player2 == choices[1]: # Lizard eats Paper
       return 'win'
   elif player1 == choices[1] and player2 == choices[4]: # Paper disproves Spock
       return 'win'
   elif player1 == choices[4] and player2 == choices[0]: # Spock vaporises Rock
       return 'win'
   elif player1 == choices[0] and player2 == choices[2]: # Rock crushes Scissors
       return 'win'
   elif player1 == player2:
       return 'draw'
   else:
       return 'lose'

human_player function mentioned above is mostly right with just a correction of indentation. I have shared the update code below:

def human_player():
   while True:
       choose = input("rock, paper, scissors, lizard or spock? ")
       if choose.lower() in choices:
           return choose.lower()
       else:
           print('Incorrect Selection')

I have also added a call to the main() function after seed(42) so as to play the game.

Screenshot of the entire code:

from random import choice, seed choices = [rock, paper, scissors, lizard, spock] def outcome (playeri, player2): if

def main(): human = human_player() computer = computer_player() print (human, outcome (human, computer), computer) if __name_

Test screenshot

rock, paper, scissors, lizard or spock? lizard lizard lose rock

rock, paper, scissors, lizard or spock? paper paper win rock

rock, paper, scissors, lizard or spock? rock rock draw rock

Add a comment
Know the answer?
Add Answer to:
5.12 A5 Program Do you want to play. a. game? The Big Bang Theory fans may...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • java pls Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of...

    java pls 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...

  • “Oh I know, let’s play Rock, Paper, Scissors, Lizard, Spock. It’s very simple.” What better way...

    “Oh I know, let’s play Rock, Paper, Scissors, Lizard, Spock. It’s very simple.” What better way to expand the classic Rock, Paper, Scissors game than to add Lizard and Spock! Sheldon and Raj brought Sam Kass’s game to life on The Big Bang Theory in “The Lizard-Spock Expansion” episode.   Assignment & Discussion Your task in Programming Assignment 8 is to create a C# console app-version of Rock, Paper, Scissors, Lizard, Spock (RPSLS). Use any of the programming tools and techniques...

  • Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember...

    Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember the rules: 1. Rock beats scissors 2. Scissors beats paper 3. Paper beats rock The program should ask the users for their names, then ask them for their picks (rock, paper or scissors). After that, the program should print the winner's name. Note, the players may pick the same thing, in this case the program should say it's tie. when the user input an...

  • IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors...

    IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....

  • Create a python program to play rock paper scissors using a while loop and if statements....

    Create a python program to play rock paper scissors using a while loop and if statements. I have started but have gotten stuck in a continuous loop. Please look over my code and help me find where I went wrong. Here it is: import random #Choice weapons=['Rock' ,'Paper' ,'Scissors'] print('Rock, Paper, Scissors!') print('Rock, Paper, Scissors!') print('Shoot!') human=input('Choose Rock, Paper, Scissors, or Quit! ') print('')#Blank Line while human != 'Quit': human_choice=human computer=random.choice(weapons) print(computer) if human==computer: print("It's a tie!") elif human=='Rock': if...

  • (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against...

    (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. The...

  • Python please. I have a working one that doesn't keep track of w/l ratio, it may...

    Python please. I have a working one that doesn't keep track of w/l ratio, it may be helpful to see how others did the entire program and inserted that module. Write a modular program that let the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 thru 3 is generated but do not display the computer choice immediately. Number 1...

  • The game lets players know whether they have won, lost, or tied a particular game. Modify...

    The game lets players know whether they have won, lost, or tied a particular game. Modify the game so the players are told the number of games they have won, lost or tied since the start of game play. Implement this change by adding three variables named $wins, $lost, and $ties to the program's Main Script Logic section, assigning each an initial value of 0. Next, modify the analyze_results method by adding programming logic that increments the values of $wins,...

  • Java Listed below is code to play a guessing game. In the game, two players attempt...

    Java Listed below is code to play a guessing game. In the game, two players attempt to guess a number. Your task is to extend the program with objects that represent either a human player or a computer player. boolean checkForWin (int guess, int answer) { System.out.println("You guessed" + guess +"."); if (answer == guess) { System.out.println( "You're right! You win!") ; return true; } else if (answer < guess) System.out.println ("Your guess is too high.") ; else System.out.println ("Your...

  • It's writing a simple rock paper scissors game strictly following the instructions. INSTRUCTIONS: If the user...

    It's writing a simple rock paper scissors game strictly following the instructions. INSTRUCTIONS: If the user selects 'p': 1. First the program should call a function named getComputerChoice to get the computer's choice in the game. The getComputerChoice function should generate a random number between 1 and 3. If the random number is 1 the computer has chosen Rock, if the random number is 2 the user has chosen Paper, and if the random number is 3 the computer has...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT