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
Rounding up and down for 389,422
elena-14-01-66 [18.8K]

Answer:

389420

389430

Explanation:

the up is for 389430

the down is for 389420

4 0
3 years ago
Supervisor: You will need to consolidate your trouble tickets
liubo4ka [24]
Wheres the rest???????????????????
7 0
3 years ago
6. Which of the following is malware? (1 point)
marusya05 [52]
Software to damage computers
5 0
3 years ago
Read 2 more answers
Write a Java program that prints out a 4x4 square (like the one below)
Sindrei [870]

public class 4by4Square

{

    public static void main(){

       System.out.println("xxxx \nx  x\nx  x\nxxxx");

    }

}

<h2><u>~CaptnCoderYankee</u></h2>
5 0
3 years ago
Question 8 of 25
denis23 [38]

Answer:

D to Protect sensitive data, Enterprise has certain security features and is mostly used in business settings.

5 0
2 years ago
Other questions:
  • Why is it important to evaluate the website on which you plan to shop?
    11·2 answers
  • The acceleration of a body is 3 metre per second square what does it mean​
    11·2 answers
  • Calculate the change in RGDP if the MPC is .6 and initial spending is $500,000.
    8·1 answer
  • When a bank account pays compound interest, it pays interest not only on the principal amount that was deposited into the accoun
    10·1 answer
  • A(n) _______ gate provides an output of 1 if either or both inputs are 1.
    14·2 answers
  • In relation to data science,advances in technology has made it more feasible to do what
    5·1 answer
  • Pride Group of Companies is making tremendous profits in different categories of electronic goods. The group of managers have to
    12·1 answer
  • What are some of the ways we can resolve IPv4 address shortages? Check all that apply.
    13·1 answer
  • How many questions do you have to answer before you can use direct messages on Brainly?
    13·2 answers
  • The most important preinstalled software is the ______ software that allows you to use the computer the first time you turn it o
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!