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
Your organization's network has multiple layers of security devices. When you attempt to connect to a service on the Internet. H
Sindrei [870]

Answer:

The host-based firewall settings are blocking the service

Explanation:

Host-based firewall settings can be configured on each workstation. The firewall can be provided by the operating system itself, or it can be a standalone software package that provides security features and functionality for the device's network connection. If this firewall contains incorrect settings, legitimate services can be blocked, and if so, a message will usually notify the user of such a breach. In these cases, the firewall settings need to be adjusted to make the desired service work.

7 0
3 years ago
Louis is a civil engineer and wants to use a line on a floor plan that is indicative of the position from which a section is tak
frutty [35]

Answer:

A

Explanation:

horizontal line

8 0
2 years ago
Read 2 more answers
In learning information security, it is important to understand that threats to your company's information assets are present 24
coldgirl [10]

1. Acts of human error

<u>Explanation:</u>

Insecurity their are many threats that make a desktop or workstation or laptop.  Normally end users have to update operating systems and virus signature updates by periodic scheduling task moreover to avoid threats end-user also have to do periodic scheduling scanning. And the virus cleaning. Download the third-party malware and spyware and then the cleaning process.

End-users have made sure all required service is activated and running in the organization.

The team has to make sure any software threats are found in PC or workstation or laptop or desktop or LAN and try to remove make system up running without any threats.

8 0
3 years ago
Write a program that takes an integer n as a parameter and sums all of the multiples of 2 or 5 from 1 to n. For example, if n =
Alex

Answer:

// here is code in c++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main() {

// variable

int num;

int tot_sum=0;

cout<<"enter a number: ";

// read the value of n

cin>>num;

// check the multiple of 2 or 5 from 1 to n

for(int x=1;x<=num;x++)

{

// if multiple of 2 or 5 then add them

   if(x%2==0 ||x%5==0)

   {

       tot_sum=tot_sum+x;

   }

}

// print the sum

cout<<"sum of multiple of 2 or 5 is:"<<tot_sum<<endl;

return 0;

}

Explanation:

Read the number "n" from user.Check every number from 1 to n, if it is a multiple of 2 or 5 then add them to "tot_sum".When the for loop end, "tot_sum" will have sum of all the number which are either multiple of 2 or 5.Print the sum.

Output:

enter a number:11

sum of multiple of 2 or 5 is:35

4 0
3 years ago
Typing with capital letters and exclamation points in an e-mail is an example of
Aleks [24]
It's an example of a poorly written email, it looks like somebody is angry and yelling at you, these types of emails can be described as a poor etiquette.
3 0
3 years ago
Read 2 more answers
Other questions:
  • A database on a mobile device containing bands, sub-bands and service provider IDs allowing the device to establish connection w
    9·1 answer
  • Anti-bullying laws in most states are designed to provide
    14·2 answers
  • ____________________ is the premeditated, politically motivated attacks against information, computer systems, computer programs
    6·2 answers
  • How does LinkedIn differ from other popular social media platforms? What are the similarities?
    6·1 answer
  • The piece of hardware that contains the circuitry that processes the information coming in to the computer and tells the other h
    8·1 answer
  • How is a microkernel architecture different from a monolithic architecture?
    5·1 answer
  • Write a program to read a list of exam scores given as integer percentages in the range 0-100. Display the total number of grade
    10·1 answer
  • Technical term of stealing personal information in social media.​
    5·1 answer
  • WILL GIVE BRAINLIEST!!! Danielle is warehouse supervisor for a large shipping company. Most shipments need to leave the warehous
    7·1 answer
  • What does playstation network is currently undergoing maintenance?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!