Question

Write a Python program (using python 3.7.2) that lets the user play the game of Rock,...

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

computer’s choice yet.)

2. The user enters his

or her choice of “rock”, “paper”, or “scissors” at the keyboard. (You can use

a menu if you prefer.)

3. The computer’s choice is displayed.

4. A winner is selected according to the following rules:

a. The rock smashes the scissors.

b. Scissors cuts paper.

c. Paper wraps rock.

d. If both players make the same choice it is a tie.

Print who the winner is.

Part B:

Once you have completed Part A continue playing, keeping track of how many wins, losses and ties. Add

an item to the menu that asks if the user wants to Quit. Keep playing until the user selects Quit. Print out the totals.

USE COMMENTS.

Notes: To generate a random integer 1 ,2 or 3:

Import random

num=random.randint(1,3)

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

Code:-

import random #importing libraries
win=0 #initially declare win with 0
lose=0 #initially declare lose with 0
tie=0 #initially declare lose with 0
while(True): #infinite loop
num=random.randint(1,3) #chose random number between 1 and 3
user=int(input("Enter Your Choice 1)rock 2)paper 3)scissors 4)quit: ")) #take input from user menu driven
if user==1: #if user selects rock
if num==1: #if computer chooses rock
print("Computer chooses rock")
print("Both chooses rock")
tie=tie+1
if num==2: #if computer chooses paper
print("Computer chooses paper")
print("paper wraps rock user loses")
lose=lose+1
if num==3: #if computer chooses scissors
print("Computer chooses scissors")
print("rock smashes scissors user wins")
win=win+1
  
elif user==2: #if user selects paper
if num==2: #if computer chooses paper
print("Computer chooses paper")
print("Both chooses paper")
tie=tie+1
if num==3: #if computer chooses scissors
print("Computer chooses scissors")
print("Scissors cuts paper user loses")
lose=lose+1
if num==1: #if computer chooses rock
print("Computer chooses rock")
print("paper wraps rock user wins")
win=win+1
elif user==3: #if user selects scissors
if num==3: #if computer chooses scissors
print("Computer chooses scissors")
print("Both chooses scissors")
tie=tie+1
if num==1: #if computer chooses rock
print("Computer chooses rock")
print("rock smashes scissors user loses")
lose=lose+1
if num==2: #if computer chooses paper
print("Computer chooses paper")
print("Scissors cuts paper user wins")
win=win+1
elif user==4: #if user want to quit
break
else: #if choice is invalid
print("Invalid choice")
print("Total Wins",win) #printing total wins
print("Total loses",lose) #printing total loses
print("Total ties",tie) #printing total ties

Code Screen Shot:-

Output:-

#Any Doubts please comment

Add a comment
Know the answer?
Add Answer to:
Write a Python program (using python 3.7.2) that lets the user play the game of Rock,...
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
  • In python language Write a program that lets the user play the game of Rock, Paper,...

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

  • C++ Part 2: Rock Paper Scissors Game Write a program that lets the user play this...

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

  • (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...

  • In JAVA Chapter 5Assignment(Rock, Paper, Scissors)–20pointsYour goal is towrite a program that lets the user play...

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

  • In this problem, you’ll play a simple rock, paper, scissors game. First, you’ll ask the user...

    In this problem, you’ll play a simple rock, paper, scissors game. First, you’ll ask the user to pick rock, paper, or scissors. Then, you’ll have the computer randomly choose one of the options. After that, print out the winner! You should keep playing the game until the user hits enter. Note: You’ll need to implement a method called String getWinner(String user, String computer). Luckily, you just wrote that in an earlier program! Here is a sample run of the program....

  • 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...

  • 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...

  • Using python 3.7.3 Challenge: Rock, Paper, Scissors GamePDF Description: Create a menu-driven rock, paper, scissors game...

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

  • (C++) Hey guys we just went over loops and it got me confused, it has me...

    (C++) Hey guys we just went over loops and it got me confused, it has me scrathcing my head for the past two days. I would appreciate any help you guys have to offer. Few places I have a hard time is get input and determine winner(cummulative part). Write a program that lets the user play the Rock, Paper, Scissors game against the computer. The computer first chooses randomly between rock, paper and scissors, but does not display its choice....

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