Write a program in python that lets the user play the game Rock, Paper, Scissors against the computer. The program should work as follows:
import random random.seed(300)
Use the following functions in your design. They will be unit tested:
getPlayerChoice()
getComputerChoice()
determineWinner(computerChoice, playerChoice)
convertChoice(choice);
main()
if __name__ == '__main__':
main()
Your file main.py will look like this:
import random
random.seed(300)
def determineWinner(playerChoice, computerChoice):
```statements```
def convertChoice(choice):
```statements```
def getComputerChoice():
```statements```
def getPlayerChoice():
```statements```
# Main
def main():
#get the player choice
#generate the computer choice
#while the user has not chosen 4
#print the player choice as a string
#print the computer choice as a string
#print the winner as a string
#get new choices for the player and computer
if __name__ == '__main__':
main()import random
random.seed(300)
def determineWinner(playerChoice, computerChoice):
# Check who won and print
if computerChoice == 1 and playerChoice == 2:
return "Player wins!"
elif computerChoice == 2 and playerChoice == 1:
return "Computer wins!"
elif computerChoice == 3 and playerChoice == 1:
return "Player wins!"
elif computerChoice == 1 and playerChoice == 3:
return "Computer wins!"
elif computerChoice == 2 and playerChoice == 3:
return "Player wins!"
elif computerChoice == 3 and playerChoice == 2:
return "Computer wins!"
else:
return "Tie!"
def convertChoice(choice):
# Return respective value to number
if choice == 1:
return 'rock'
elif choice == 2:
return 'paper'
else:
return 'scissors'
def getComputerChoice():
return random.randint(1, 3)
def getPlayerChoice():
# Ask user to enter either of four
choice = int(input('1. rock, 2. paper, 3. scissors or 4 to exit: '))
# Keep asking till user enters a valid input
while choice not in [1, 2, 3, 4]:
choice = int(input('1 .rock, 2. paper, 3. scissors or 4 to exit: '))
return choice
# Main
def main():
player = getPlayerChoice() # get the player choice
comp = getComputerChoice() # generate the computer choice
while player != 4: # while the user has not chosen 4
# print the player choice as a string
print('Player''s Choice:', convertChoice(player))
# print the computer choice as a string
print('Computer''s Choice:', convertChoice(comp))
# print the winner as a string
print(determineWinner(player, comp))
print()
# get new choices for the player and computer
player = getPlayerChoice()
comp = getComputerChoice()
if __name__ == '__main__':
main()
SCREENSHOT


OUTPUT

Write a program in python that lets the user play the game 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...
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....
(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 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...
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...
In python language
Write a program 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 and 3 is generated. 1 = Computer has chosen Rock 2 = Computer has chosen Paper 3 = Computer has chosen Scissors (Dont display the computer's choice yet) 2. The user enters his or her choice of “Rock”, “Paper", “Scissors" at...
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...
JAVA Beginnings of a paper-rock-scissors game. Paper-rock-scissors is a game often used to make decisions. There are two players. Each player secretly chooses either, paper, rock or scissors. At the count of three, each player reveals what they have chosen. The winner of the game is determined this way: paper beats rock (because paper covers rock) rock beats scissors (because rock crushes scissors) scissors beat paper (because scissors cut paper) If the two players choose the same item, it is...
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 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...