1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Simora [160]
3 years ago
8

Design a program in python that is able to take a user's input of either "Rock", "Paper", or "Scissors" and based on their input

, output to them what their choice will beat in a "rock, paper, scissors" game. Additionally, if the user misspells or enters a wrong input tell them that they have made a mistake.
Computers and Technology
2 answers:
MAXImum [283]3 years ago
6 0

Answer: <em>This is the simplest rock paper scissor game that a beginner in python can understand:</em>

<em />

<em>******************************************************************************************</em>

<em>import sys                                        #sys module is for exit function in line 8</em>

<em>import random</em>

<em>import time </em>

<em>print("Hi!,Welcome to TEENS Rock paper,scissor,game")</em>

<em>name = str(input("What's Your Name? -"))</em>

<em>print("HI",name,"!")</em>

<em>age  = float(input(" Please Enter your Age :"))</em>

<em>if age < 13:</em>

<em>    sys.exit('You are not eligible as you are not a Teenager.')</em>

<em>else :</em>

<em>    input("can we start the game? :")</em>

<em>rules = str(input("Do you know the rules of the game?:"))</em>

<em>if rules == 'no':</em>

<em>    print(" RULES: An easily memorised rule determines the winner: “Rock breaks scissors, scissors cuts paper, paper covers rock.”\n In other words, a player who chooses rock beats one who chooses scissors; scissors in turn beats paper; paper beats rock. This yields a winner whenever the two players choose differently.")</em>

<em>    print("\nLoading..")           #remember to Continue the game also after here</em>

<em>    </em>

<em>elif rules =='yes':</em>

<em>    print("Loading..")</em>

<em>    time.sleep(1)</em>

<em>    print("processing..")</em>

<em>    time.sleep(1)</em>

<em>    print("bringing Papers,scissors,Rocks...")</em>

<em />

<em>print("_____________________________________________")</em>

<em>CHOICES = ['rock','paper','scissor']</em>

<em />

<em>userchoice = str(input("What is your Choice [rock,paper,scissor]? : "))</em>

<em>compchoice = random.choice(CHOICES)</em>

<em>print("Computer's Choice=",compchoice)</em>

<em />

<em>if userchoice == compchoice:</em>

<em>    print("DRAW!")</em>

<em>    print("Compchoice:",compchoice)</em>

<em>    time.sleep(2)</em>

<em>elif userchoice == 'paper' and compchoice == 'rock':</em>

<em>    print("Paper Covers Rock!!" )</em>

<em>    print(name,"Wins !!")</em>

<em>elif userchoice == 'rock' and compchoice == 'paper':</em>

<em>    print("Paper Covers Rock!!" )</em>

<em>    print("Computer Wins !!")</em>

<em>elif userchoice == 'paper' and compchoice == 'scissor':</em>

<em>    print("scissor Cuts paper!!" )</em>

<em>    print("Computer Wins !!")</em>

<em>elif userchoice == 'scissor' and compchoice == 'paper':</em>

<em>    print("scissor Cuts paper!" )</em>

<em>    print(name,"Wins !!")</em>

<em>elif userchoice == 'rock' and compchoice == 'scissor':</em>

<em>    print("Rock breaks scissor!" )</em>

<em>    print(name,"Wins !!")</em>

<em>elif userchoice == 'scissor' and compchoice == 'rock':</em>

<em>    print("Rock breaks scissor!" )</em>

<em>    print("Computer Wins !!")</em>

<em>    </em>

<em>userchoice = str(input("What is your Choice [rock,paper,scissor]? : "))</em>

<em>compchoice = random.choice(CHOICES)</em>

<em>print("Computer's Choice=",compchoice)</em>

<em />

<em>if userchoice == compchoice:</em>

<em>    print("DRAW!")</em>

<em>    print("Compchoice:",compchoice)</em>

<em>    time.sleep(2)</em>

<em>elif userchoice == 'paper' and compchoice == 'rock':</em>

<em>    print("Paper Covers Rock!!" )</em>

<em>    print(name,"Wins !!")</em>

<em>elif userchoice == 'rock' and compchoice == 'paper':</em>

<em>    print("Paper Covers Rock!!" )</em>

<em>    print("Computer Wins !!")</em>

<em>elif userchoice == 'paper' and compchoice == 'scissor':</em>

<em>    print("scissor Cuts paper!!" )</em>

<em>    print("Computer Wins !!")</em>

<em>elif userchoice == 'scissor' and compchoice == 'paper':</em>

<em>    print("scissor Cuts paper!" )</em>

<em>    print(name,"Wins !!")</em>

<em>elif userchoice == 'rock' and compchoice == 'scissor':</em>

<em>    print("Rock breaks scissor!" )</em>

<em>    print(name,"Wins !!")</em>

<em>elif userchoice == 'scissor' and compchoice == 'rock':</em>

<em>    print("Rock breaks scissor!" )</em>

<em>    print("Computer Wins !!")</em>

<em />

<em>userchoice = str(input("What is your Choice [rock,paper,scissor]? : "))</em>

<em>compchoice = random.choice(CHOICES)</em>

<em>print("Computer's Choice=",compchoice)</em>

<em />

<em>if userchoice == compchoice:</em>

<em>    print("DRAW!")</em>

<em>    print("Compchoice:",compchoice)</em>

<em>    time.sleep(2)</em>

<em>elif userchoice == 'paper' and compchoice == 'rock':</em>

<em>    print("\tPaper Covers Rock!!" )</em>

<em>    print("\t",name,"Wins !!")</em>

<em>elif userchoice == 'rock' and compchoice == 'paper':</em>

<em>    print("\tPaper Covers Rock!!" )</em>

<em>    print("\tComputer Wins !!")</em>

<em>elif userchoice == 'paper' and compchoice == 'scissor':</em>

<em>    print("\tscissor Cuts paper!!" )</em>

<em>    print("\tComputer Wins !!")</em>

<em>elif userchoice == 'scissor' and compchoice == 'paper':</em>

<em>    print("\tscissor Cuts paper!" )</em>

<em>    print("\t",name,"Wins !!")</em>

<em>elif userchoice == 'rock' and compchoice == 'scissor':</em>

<em>    print("\tRock breaks scissor!" )</em>

<em>    print(name,"Wins !!")</em>

<em>elif userchoice == 'scissor' and compchoice == 'rock':</em>

<em>    print("Rock breaks scissor!" )</em>

<em>    print("Computer Wins !!")</em>

<em>print("\n\n\t\a GameOver !!")</em>

<em>print("\n\n\t\aThank you For playing !!")</em>

<u></u>

Sedbober [7]3 years ago
4 0

Answer:

Here you go:

Explanation:

# 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. Rock \n 2. paper \n 3. 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")  

You might be interested in
1. in terms of technology, we often said to be living in the _____ age.???
sleet_krkn [62]
I think its the new age either that or end times
3 0
3 years ago
Read 2 more answers
Code the function definition for aNonclassFunction, picking up co. aNonclassFunction has no return value.
enot [183]

Answer:

b)void aNonclassFunction (Banana co);

Explanation:

In the function definition you have to pass the tell the function which type of argument it is taking.In our case we are taking a variable co of Banana type passing it to the function named aNonclassFunction having no return type.

So the definition will be like this.

void aNonclassFunction (Banana co);

6 0
3 years ago
Does the sticker list an automatic or manual transmission?
pantera1 [17]
Automatic, three speed transmission
5 0
4 years ago
Read 2 more answers
Which option will enable Mina to apply several formats to the spreadsheet cells at the same time?
madam [21]
Applying a cell style will enable Mina to apply several formats to the spreadsheet cells at the same time.  <span>To apply several formats in one step, and to make sure that cells have consistent formatting, you can use a cell style. A cell style is a defined set of formatting characteristics, such as fonts and font sizes, number formats, cell borders, and cell shading. </span>
4 0
3 years ago
HELP BRAINLIEST FOR RIGHT ANSWER
Scilla [17]

Answer:

true I know this cuz I smart

7 0
3 years ago
Read 2 more answers
Other questions:
  • In this assignment, you are going to add conditional formatting to the spreadsheet you used in the previous
    13·1 answer
  • End-user development: the process by which an organization's non-it specialists create software applications.
    8·1 answer
  • PLEASE HELP!
    12·2 answers
  • 1. Itemise the order in which BASIC executes arithmetic operation.
    13·1 answer
  • The calculation of the likelihood of an attack coupled with the attack frequency to determine the expected number of losses with
    12·1 answer
  • Jenis jenis perangkat keras?
    14·1 answer
  • Why do Selection Sort and Insertion Sort’s outer loops run 11 iterations if there are 12 elements in the array?
    7·1 answer
  • When a guest is wearing the medallion, they can order a drink with their smartphone or open their cabin door automatically by st
    13·1 answer
  • Give one (1) advantage and one(1) disadvantage of using and integrated software package over a custom written one.
    15·1 answer
  • Add comma(s) where needed, if needed.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!