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
You are given a string of n characters s[1 : : : n], which you believe to be a corrupted text document in which all punctuation
alexdok [17]

Answer: provided in the explanation section

Explanation:

Given that:

Assume D(k) =║ true it is [1 : : : k] is valid sequence  words or false otherwise

  • To determine D(n)

now the sub problem s[1 : : : k] is a valid sequence of words IFF s[1 : : : 1] is a valid sequence of words and s[ 1 + 1 : : : k] is valid word.

So, from here we have that D(k) is given by the following recorance relation:

D(k) = ║ false maximum (d[l]∧DICT(s[1 + 1 : : : k]) otherwise

Algorithm:

Valid sentence (s,k)

D [1 : : : k]             ∦ array of boolean variable.

for a ← 1 to m

do ;

d(0) ← false

for b ← 0 to a - j

for b ← 0 to a - j

do;

if D[b] ∧ DICT s([b + 1 : : : a])

d (a) ← True

(b). Algorithm Output

      if D[k] = = True

stack = temp stack           ∦stack is used to print the strings in order

c = k

while C > 0

stack push (s [w(c)] : : : C] // w(p) is the position in s[1 : : : k] of the valid world at // position c

P = W (p) - 1

output stack

= 0 =

cheers i hope this helps !!!

8 0
3 years ago
What are examples of people who own the copyrights of their property? Check all that apply.
jolli1 [7]
"Nevaeh thinks of a name for her new company", "Alexis thinks of an idea for a new product" and "Josiah writes a poem" are open to copyright because they can claim that their work is original and cannot be reproduced without their consent. 
3 0
3 years ago
Read 2 more answers
The database structure in a dbms is stored as a _____.
Colt1911 [192]
This will be stored as a collection of files
6 0
3 years ago
A computer system has 9,850 processes and 172 of them were suspended while 276 of them were terminated. Explain why some of the
Mrrafil [7]

Answer:

Check below for answers and explanations.

Explanation:

The major reasons why computer processes are suspended or terminated are:

1. When there is insufficient memory for successful completion of the process

2. When there's an unauthorized access of any of the computer resources by the process.

It is possible that some processes are terminated why some are suspended because, when the system runs out of memory, the running processes are put on hold until the system is able to create free memory space for the completion of the process. In this case the process is suspended. But if the system cannot provide enough space for the process, the process is terminated.

In the example provided in this exercise, some of the processes were suspended because the system wants to create free memory space for their completion while others are terminated either because the available space is not sufficient for their completion or they want to access an unauthorized resources on the system.

4 0
3 years ago
What internal commands can we use when in interactive mode? can we use CLS and CD?
krok68 [10]
The cd command, also known as chdir (change directory), is a command-line shell command used to change the current working directory in various operating systems. It can be used in shell scripts and batch files.
3 0
3 years ago
Other questions:
  • You have been asked to create an authentication security plan for your company. Which of the following components would you inco
    14·1 answer
  • Lance has three tables in his database he wants to generate a report to show the data from the three table so he decides to link
    6·2 answers
  • So how do I repost a answer that I already answered to a question because I answered this question but later it told me to repos
    14·1 answer
  • Compare the logical link control and the media access control. Which of the following is a correct statement?
    7·2 answers
  • What career cluster does a fish and game warden fall in?
    14·1 answer
  • You can use this type of program to create a new raster image
    9·1 answer
  • A process at Host C receiving two incoming UDP segments from two different hosts will know that they originated from two differe
    14·2 answers
  • Why are computers useful for modeling situations?
    13·2 answers
  • There are many potential risks associated with the internet. what do we call the distribution and access of illegal copies of di
    7·1 answer
  • In a database, what term is used to describe a group of fields that are all associated with and accessed using single primary ke
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!