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
Over the past year alone, more than _________ have been stolen from Target.
jasenka [17]
40 million (google said so)
6 0
3 years ago
Read 2 more answers
What does the third argument (3) refer to in the following formula: VLOOKUP(10005, A1:C6, 3, FALSE)
zzz [600]

Answer:

The answer is "number of the column containing the return value".

Explanation:

In Excel, the "VLOOKUP" method is used to perform the vertical search by looking for both the value during the user table and retrieving the number of the index number location in the same row. It is a built-in function, which is classified as a Lookup or Reference worksheet function, and the following function can be defined as follows:

  • In the 1st parameter, it is used to watch the value for the match.  
  • In the 2nd parameter, it is used to search the table.
  • In the 3rd parameter, it is used as the column number representing the return value.  
  • In the 4th parameter, it is used to return only if the same match is found.
5 0
3 years ago
Python code 100 Random Numbers (twice)
Leona [35]

import random

i = 1

while i <= 100:

   print("#"+str(i)+": "+str(random.randint(1,100)), end=", ")

   i+=1

print()

i = 1

while i <= 100:

   print("#"+str(i)+": "+str(random.uniform(1,100)), end=", ")

   i += 1

I hope this helps!

8 0
2 years ago
In what ways can information be slanted in a news report?
ratelena [41]

Answer:It all depends on who the reader is likely to be and the information they’ll want.

Explanation:

Newspaper 1: Company wins contract

Newspaper 2: Previous company loses contract (equally true)

Newspaper 3, say a student paper in the local town: Prospects for new jobs open up as company wins contract.

8 0
1 year ago
Martha and her project group want to present the class their work in the form of a slideshow that includes charts. Which applica
Gennadij [26K]

Answer:

Your answer is D.  multimedia software

Explanation:

6 0
3 years ago
Other questions:
  • 3. If B3=6 and D5=8, what would the following function return? IF(B3&gt;D5, "Closed", D5-B3) *
    10·2 answers
  • Which of these is an on-site metric for social media marketing?
    13·1 answer
  • What is the purpose of this diamond shape in a flowchart?
    8·1 answer
  • ​You work at a call center of a large bank where you answer credit card services related questions from customers. Lately, you h
    14·1 answer
  • If you're using the paintbrush tool and want to change the color of the paint being used what should you change
    6·1 answer
  • Which of the following can be considered beta testing? A programmer at Linus Systems checks the integration of multiple modules
    14·1 answer
  • After separating from Mexico, Texas passed laws that made it harder for slave owners to _____________ slaves.
    12·2 answers
  • Consider the following code segment
    15·1 answer
  • Employing the use of a(n) <br> will help you manage a STEM project.
    13·1 answer
  • Were can i watch unexpected free season 3
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!