//code
from random import randint
options = ["Rock", "Paper", "Scissors"]
#choosing options for computer randomly
computer_choice = options[randint(0,2)]
#set player to False
player = False
#we keep on playing till player doesn't want to play
while player == False:
#set player to True
#Taking input from the user and displaying it only in the correct cases
player = input("Rock, Paper, Scissors? ")
if player == "Rock" or player == "Paper" or player == "Scissors":
print("You entered: ", player)
#tie in case of same generated for computer
if player == computer_choice:
print("Tie!")
elif player == "Rock":
if computer_choice == "Paper":
print("You lose!", computer_choice, "covers", player)
else:
print("You win!", player, "smashes", computer_choice)
elif player == "Paper":
if computer_choice == "Scissors":
print("You lose!", computer_choice, "cut", player)
else:
print("You win!", player, "covers", computer_choice)
elif player == "Scissors":
if computer_choice == "Rock":
print("You lose...", computer_choice, "smashes", player)
else:
print("You win!", player, "cut", computer_choice)
else:
print("That's not a valid play. Check your spelling!")
player = False
continue
#player was set to True, but we want it to be False so the loop continues
choice = input("Do you want to continue playing Y/N? ")
if choice.lower() == 'y':
player = False
else:
player = True
#generating computer's choice for the next game
computer_choice = options[randint(0,2)]
//output
Explanation:
We have created a list of all three options and every time we are using python's random number generation library for generating a random integer between 0 to 2. We will use this integer as the index of our list and give the value at that particular index as the computer's choice. We will then compare computer's randomly generated choice with user's choice for different cases.
CECS Project 1 RPS (Rock-Paper-Scissors) Game Use python This project asks you to practice . creating...
Using python 3.7.3 Challenge: Rock, Paper, Scissors GamePDF Description: Create a menu-driven rock, paper, scissors game in Python 3 that a user plays against the computer with the ability to save and load a game and its associated play statistics. Purpose: The purpose of this challenge is to assess the developer’s ability to create an interactive application with data persistence in Python 3. Requirements: Create a Rock, Paper, Scissors game in Python named rps.py according to the requirements specified in...
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...
Java CSC252 Programming II Static Methods, Enums, Constants, Random Rock Paper Scissors Write a program that allows the user to play "Rock, Paper, Scissors". Write the RPS class. All code should be in one file. main() will be part of the RPS class, fairly small, and contain only a loop that asks the user if they want to play "Rock, Paper, Scissors". If they say yes, it calls the static method play() of the RPS class. If not, the program...
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...
Help needed in Perl language program!
Note : Perl Language
Rock, Paper, Scissors (also known by several other names, see http://en.wikipedia.org/wiki/Rock paper scissors) is an extremely popular hand game most often played by children. Often, it is used as a method of selection similar to flipping a coin or throwing dice to randomly select a person for some purpose. Of course, this game is not truly random since a skilled player can often recognize and exploit the non-random behavior of...
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...
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...
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...
This program should be in c++. Rock Paper Scissors: This game is played by children and adults and is popular all over the world. Apart from being a game played to pass time, the game is usually played in situations where something has to be chosen. It is similar in that way to other games like flipping the coin, throwing dice or drawing straws. There is no room for cheating or for knowing what the other person is going to...
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....