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
weqwewe [10]
3 years ago
5

ROCK-PAPER-SCISSORS Write a program that plays the popular game of rock-paper-scissors. (A rock breaks scissors, paper covers ro

ck, and scissors cut paper). The program has two players and prompts the users to enter rock, paper or scissors. Your program does not have to produce any color. The color is there just to show you what your program should be inputting and outputting. The writing in blue represents output and writing in red represents input. Here are some sample runs:
Computers and Technology
1 answer:
stepladder [879]3 years ago
8 0

Answer:

In Python

print("Instruction: 1. Rock, 2. Paper or 3. Scissors: ")

p1 = int(input("Player 1: "))

p2 = int(input("Player 2: "))

if p1 == p2:

   print("Tie")

else:

   if p1 == 1: # Rock

       if p2 == 2: #Paper

           print("P2 wins! Paper covers Rock")

       else: #Scissors

           print("P1 wins! Rock smashes Scissors")

   elif p1 == 2: #Paper

       if p2 == 1: #Rock

           print("P1 wins! Paper covers Rock")

       else: #Scissors

           print("P2 wins! Scissors cuts Paper")

   elif p1 == 3: #Scissors

       if p2 == 1: #Rock

           print("P2 wins! Rock smashes Scissors")

       else: #Paper

           print("P1 wins! Scissors cuts Paper")

Explanation:

This prints the game instruction

print("Instruction: 1. Rock, 2. Paper or 3. Scissors: ")

The next two lines get input from the user

<em>p1 = int(input("Player 1: "))</em>

<em>p2 = int(input("Player 2: "))</em>

If both input are the same, then there is a tie

<em>if p1 == p2:</em>

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

If otherwise

else:

The following is executed if P1 selects rock

   if p1 == 1: # Rock

If P2 selects paper, then P2 wins

<em>        if p2 == 2: #Paper</em>

<em>            print("P2 wins! Paper covers Rock")</em>

If P2 selects scissors, then P1 wins

       else: #Scissors

           print("P1 wins! Rock smashes Scissors")

The following is executed if P1 selects paper

   elif p1 == 2: #Paper

If P2 selects rock, then P1 wins

<em>        if p2 == 1: #Rock</em>

<em>            print("P1 wins! Paper covers Rock")</em>

If P2 selects scissors, then P2 wins

<em>        else: #Scissors</em>

<em>            print("P2 wins! Scissors cuts Paper")</em>

The following is executed if P1 selects scissors

   elif p1 == 3: #Scissors

If P2 selects rock, then P2 wins

<em>        if p2 == 1: #Rock</em>

<em>            print("P2 wins! Rock smashes Scissors")</em>

If P2 selects paper, then P1 wins

<em>        else: #Paper</em>

<em>            print("P1 wins! Scissors cuts Paper")</em>

You might be interested in
What is the Multiple Source Test
Goshia [24]
A source is where you can look to find info. Multiple means many or some. 

Therefore, a multiple source test is a test that you can find the answers in multiple sources, such as a book, article, journal, etc. 
7 0
3 years ago
Read 2 more answers
Que significa el término “Informática”?
Ad libitum [116K]

Answer:

Explanation:

proviene del francés informatique, implementado por el ingeniero Philippe Dreyfus a comienzos de la década del '60. ... De esta forma, la informática se refiere al procesamiento automático de información mediante dispositivos electrónicos y sistemas computacionales.

4 0
3 years ago
What is Computer categories
MA_775_DIABLO [31]
Computer Categories are like

Supercomputers, mainframe computers, microcomputers, mobile computers, minicomputers.

I hope that this is the type of answer that you were looking for.
5 0
3 years ago
Many company websites are now designed to do more than just sell a product. These​ websites, known as​ __________ websites, atte
Zinaida [17]

Answer:

brand community

Explanation:

Many company websites are now designed to do more than just sell a product. These​ websites, known as​ brand community websites, attempt to build closer customer relationships and generate engagement with and between the brand and its customers. These online communities bring together consumers who have shared interests in a brand or product. One advantage of online brand communities is that they reduce customer support costs as the business has more engagement with their customers.This also helps the business to retain customers through brand improvement centered around the customer's actual needs.

5 0
3 years ago
Can an engine run on air? I think it can, but I am not sure
Svetlanka [38]

Hello,

NO, and engine can run on steam, gas and other things but not air.

-Bella

3 0
3 years ago
Read 2 more answers
Other questions:
  • When a user receives an email warning about the dire consequences of possible virus attacks on their pc or tablet, it is often a
    6·1 answer
  • Every preprocessing directive must begin with:
    11·1 answer
  • What will happen if you change data that is used in a formula
    10·1 answer
  • . Network navigation devices, such as routers, help datatravel in bundles that are referred toas………..
    14·1 answer
  • Learning about public speaking can help improve your ________________.
    15·1 answer
  • Write multiple if statements. if caryear is 1969 or earlier, print "probably has few safety features." if 1970 or higher, print
    6·1 answer
  • Which of the following would be an example of a loss of record integrity in a
    12·1 answer
  • Write a C program that uses a while statement to determine and print the largest of 10 numbers input by the user. Your program s
    6·1 answer
  • Identifying correction services tasks
    14·2 answers
  • Which operation is not efficiently supported by heaps?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!