Here is the python code to the given question.
Two sample outputs are added at the end.
Code:
import random
def checkWin(userChoice,computerChoice):
"""Checks whether the user has won the game.
Parameters:
userChoice(int) : choice entered by the user.
computerChoice(int) : choice chosen by computer.
Returns:
Boolean : True if user wins and False if computer wins.
"""
if (userChoice==1 and computerChoice==3) or (userChoice==2 and computerChoice==1) or(userChoice==3 and computerChoice==2):
return True
else:
return False
def getRandomNumber():
"""Generates a random number from 1-3.
Parameters:
None
Returns:
int : random number from 1-3
"""
return random.randint(1,3)
def getName(choice):
"""Gets the text representation of the choice
Parameters:
choice(int) : choice entered by user or chosen by computer
Returns:
String : text representation of the choice
"""
if choice==1:
return "rock"
elif choice==2:
return "paper"
elif choice==3:
return "scissors"
def main():
"""Simulates Rock,Paper,Scissors game."""
computerChoice=getRandomNumber() #get computer generated choice
while True:
userChoice=int(input("Enter 1 for rock, 2 for paper , 3 for scissors: ")) #get user choice and convert it into int
print("Computer chose",getName(computerChoice)) #print computer choice
print("You chose",getName(userChoice)) #print user's choice
if userChoice==computerChoice: #check if user choice equals computer choice
print("You made the same choice as the computer. Starting over")
else:
if checkWin(userChoice,computerChoice): #check if user has won the game
print("You win the game")
else:
print("Computer wins the game")
break #exit from while loop
if __name__=="__main__":
main() #calls main
Sample Output-1:

Sample Output-2:

In python language Write a program that lets the user play the game of Rock, Paper,...
C++ Part 2: Rock Paper Scissors Game Write a program that lets the user play this game against the computer. The program should work as follows: When the program begins, a random number between 1 and 3 is generated. If the number is 1, the computer has chosen rock. If the number is 2, the computer has chosen paper. If the number is 3, the computer has chosen scissors. Don't display the computer's choice yet. Use a menu to display...
Write a Python program (using python 3.7.2) that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. 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...
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....
(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...
(c++ only)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, the user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard using a menu in a function, userChoice, that returns a character. Next, there should be a function, computerChoice, that generates the computer’s play. A random number in the range of 1 through 3 is generated. If the...
Write a program in python that lets the user play the game 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. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...
In JAVA Chapter 5Assignment(Rock, Paper, Scissors)–20pointsYour goal is towrite a program that lets the user play the game of Rock, Paper, Scissors against the computer.Your program should have the following: •Make the name of the project RockPaperScissors•Write a method that generates a random number in the range of 1 through 3. The randomly generated number will determine if the computer chooses rock, paper, or scissors. If the number is 1, then the computer has chosen rock. If the number is...
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...
Write this program using C++ , (Rock, Paper, Scissors Game – Page 373) This programming assignment is from the textbook with some slight modifications and clarifications. Here is what I am going to except from you. Your program should include at least the following functions: getComputerGuess(): this function should return a random value generated by the computer using rand function (read more about random numbers in Chapter 3 pages 126 – 128). getUsersChoice(): this function will ask the user to...
Python Language: Please see program listed below of a game called: Rock, Paper, Scissors. Please add an exception, for example if the user inputs something else other than rock, paper or scissors, the exception will print message: "Enter only rock, paper, or scissors". Also add option to keep playing the game, for example: print: "Would you like to play again? Enter Y or N". If the user says Y, the game will repeat, if N, the game will end and...