In this unit, you expanded your Python skills, and now you can really have some fun! In this lab, you are going to create a game that allows the user to play Rock, Paper, Scissors against the computer. If you aren’t familiar with this classic game, here’s how it works: two people (or a person and a computer!) each select either rock, paper, or scissors. The player who chooses the stronger object wins. Here is how the winner is determined:

Rock beats scissors because a rock can break scissors.
Paper beats rock because paper can cover a rock.
Scissors beats paper because scissors can cut paper.
Your program should do the following:

Randomly choose rock, paper, or scissors for the computer
Ask the user to choose rock, paper, or scissors
Compare the computer’s choice to the player’s choice
Announce whether the computer or the human won

Answers

Answer 1

Answer:

# import random module

import random

# Print multiline instruction

# performstring concatenation of string

print("Winning Rules of the Rock paper scissor game as follows: \n"

       +"Rock vs paper->paper wins \n"

       + "Rock vs scissor->Rock wins \n"

       +"paper vs scissor->scissor wins \n")

while True:

print("Enter choice \n 1 for Rock, \n 2 for paper, and \n 3 for scissor \n")

# take the input from user

choice = int(input("User turn: "))

# OR is the short-circuit operator

# if any one of the condition is true

# then it return True value

# looping until user enter invalid input

while choice > 3 or choice < 1:

 choice = int(input("enter valid input: "))

 

# initialize value of choice_name variable

# corresponding to the choice value

if choice == 1:

 choice_name = 'Rock'

elif choice == 2:

 choice_name = 'paper'

else:

 choice_name = 'scissor'

 

# print user choice

print("user choice is: " + choice_name)

print("\nNow its computer turn.......")

# Computer chooses randomly any number

# among 1 , 2 and 3. Using randint method

# of random module

comp_choice = random.randint(1, 3)

# looping until comp_choice value

# is equal to the choice value

while comp_choice == choice:

 comp_choice = random.randint(1, 3)

# initialize value of comp_choice_name

# variable corresponding to the choice value

if comp_choice == 1:

 comp_choice_name = 'Rock'

elif comp_choice == 2:

 comp_choice_name = 'paper'

else:

 comp_choice_name = 'scissor'

 

print("Computer choice is: " + comp_choice_name)

print(choice_name + " V/s " + comp_choice_name)

# condition for winning

if((choice == 1 and comp_choice == 2) or

(choice == 2 and comp_choice ==1 )):

 print("paper wins => ", end = "")

 result = "paper"

 

elif((choice == 1 and comp_choice == 3) or

 (choice == 3 and comp_choice == 1)):

 print("Rock wins =>", end = "")

 result = "Rock"

else:

 print("scissor wins =>", end = "")

 result = "scissor"

# Printing either user or computer wins

if result == choice_name:

 print("<== User wins ==>")

else:

 print("<== Computer wins ==>")

 

print("Do you want to play again? (Y/N)")

ans = input()

# if user input n or N then condition is True

if ans == 'n' or ans == 'N':

 break

# after coming out of the while loop

# we print thanks for playing

print("\nThanks for playing")

Explanation:

https://www.geeksforgeeks.org/python-program-implement-rock-paper-scissor-game/


Related Questions

Which idea generation method involves keeping ideas in sight and well-organized?
Mind Mapping
Synectics
Brainstorming
Design Boards

Answers

I believe that it would be mind mapping

Answer:

um i pink A, and C cause you can look in your mind to find idea if mind mapping means by that and you can brainstorm for other idea later for other thing that you need idea for that my answer if it not help you then i am sorry if did plz mark me brainliest if you can

Explanation:

Other Questions
A locker requires a three-digit code to open the lock. The code must contain one letter and two numbers, and no letter or number can be repeated. You can choose from among four letters, A, B, C, and D, and two numbers, 5 and 6.The size of the sample space is ___If a code is chosen at random, the probability that it has a letter that immediately follows an odd number is ___If a code is chosen at random, the probability that D is in the code but is not in the first position is ___ANSWER ALL 3 An equilateral triangle has sides of length 10 cm a.Calculate the perpendicular height, h, of the triangle b.Calculate the area of the triangle. Give your answers correct to one decimal place. Which guidelines should be followed when creating a works cited page using MLA format? Check all that apply.Works Cited is centered on the page.Citations are listed in chronological order.Citations are double spaced.A hanging indent is used for lengthy citations.The researchers name and address are included. HELPPPP PLEASE HELP ME WITH BASIC MATH I REALLY APPRECIATE IT ((WILL MARK AS BRAINLIEST)) Write a sentence using visual imagery 142- 132= 14+13 pls do this question for me Read the following prompt.Your task is to explain something complicated to someone completely unfamiliar the topic. For example, you may explain soccer to defend a goal to someone who has never heard of soccer or how to ride a bike to someone who has never seen one. Use expertise that are unique to you.Construct an outline that includes at least three key ideas and two supporting ideas for each main idea. Find the volume of the rectangular pyramidThank you!! What is Toussiant's goal in making the proclamation? Which is the best description of a cyclone?a dust stormrapidly changing weather in an areaa type of tornadoan area of low air pressure I need the answer fast pls Which of the following can have a negative effect on self-esteem?OOOOthe mediapeer pressurefamily membersAll of the choices are correct. is it true that two types of location are relative and absolute Which correctly describes a cross section of the square pyramid? Select three options. A square pyramid with 2 foot sides. A cross section parallel to the base is a square with side lengths of 2 ft. A cross section parallel to the base is a square with side lengths of less than 2 ft. A cross section perpendicular to the base through the top vertex is a triangle with the same dimensions as the triangular sides of the pyramid. A cross section perpendicular to the base through the top vertex is a triangle with different dimensions than the triangular sides of the pyramid. A cross section that is perpendicular to the base that does not pass through the top vertex of the pyramid is a trapezoid. which fractions are equivalent to 4/8? choose all correct answers (1/5) (2/6) (1/4) (1/2) (2/4) A simplified carbon cycle is depicted here. The release of carbon dioxide into the atmosphere can contribute to global warming.Which statements describe the processes of forest fires, fossil fuel combustion, and plant respiration? Select ALL that apply.A)They occur under anaerobic conditions primarily.B)They are all directly caused by human interventionThey are primarily the result of microbial activity.EliminateD)They all occur in the presence of oxygen to release carbon dioxide.E)They each convert organic carbon-based molecules into carbon dioxide. WHEN did hip-hop change into a big business? Consider the triangle.Which shows the order of the angles from smallest tolargest?2212BO angle A, angle B, angle CO angle B, angle A, angle CO angle B, angle C, angle AO angle C, angle A, angle B16 mengapakah atlit lelaki lebih kuat dan pantas berbanding atlit perempuan? If children are to be educated to understand the true principle of patriotism, their mother must be a patriot; and the love of mankind, from which an orderly train of virtues spring, can only be produced by considering the moral and civil interest of mankind; but the education and situation of woman, at present, shuts her out from such investigations . . . A Vindication of the Rights of Woman, Mary Wollstonecraft What is the topic? Which detail gives more information about the topic? Which sentence states the central idea?