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
DedPeter [7]
3 years ago
12

Write a program that plays the popular scissor-rockpaper game. (A scissor can cut a paper, a rock can knock a scissor, and a pap

er can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws. Here are sample runs:
scissor (0), rock (1), paper (2): 1
The computer is scissor. You are rock. You won
scissor (0), rock (1), paper (2): 2
The computer is paper. You are paper too. It is a draw
Computers and Technology
1 answer:
kolbaska11 [484]3 years ago
8 0

Answer:

import random

computer = random.randint(0, 2)

user = int(input("scissor (0), rock (1), paper (2): "))

if computer == 0:

   if user == 0:

       print("The computer is scissor. You are scissor too. It is a draw")

   elif user == 1:

       print("The computer is scissor. You are rock. You won")

   elif user == 2:

       print("The computer is scissor. You are paper. Computer won")

elif computer == 1:

   if user == 0:

       print("The computer is rock. You are scissor. Computer won")

   elif user == 1:

       print("The computer is rock. You are rock too. It is a draw")

   elif user == 2:

       print("The computer is rock. You are paper. You won")

elif computer == 2:

   if user == 0:

       print("The computer is paper. You are scissor. You won")

   elif user == 1:

       print("The computer is paper. You are rock. Computer won")

   elif user == 2:

       print("The computer is paper. You are paper too. It is a draw")

Explanation:

*The code is in Python.

Import the random to be able to generate number number

Generate a random number between 0 and 2 (inclusive) using randint() method and set it to the computer variable

Ask the user to enter a number and set it to the user variable

Check the value of computer the computer variable:

If it is 0, check the value of user variable. If user is 0, it is a draw. If user is 1, user wins. If user is 2, computer wins

If it is 1, check the value of user variable. If user is 0, computer wins. If user is 1, it is a draw. If user is 2, user wins

If it is 2, check the value of user variable. If user is 0, user wins. If user is 1, computer wins. If user is 2, it is a draw

You might be interested in
Write a program that will make a copy of a text file, line by line. Read the name of the existing file and name of the new file(
Luba_88 [7]

Answer:

To find the text file, use a full path name when entering the file name, such as

C:\textfiles\StateCapitals.txt

You can save typing in the full path name by putting the file in the project directory, such as in

C:\Users\me\Documents\NetBeansProjects\Project4

3 0
3 years ago
How many keys are on a microsoft windows standard keyboard
DiKsa [7]

There are 101 keys on a microsoft windows standard keyboard

7 0
4 years ago
Read 2 more answers
What is the term that is used to describe a computer system that could store literary documents, link them according to logical
madreJ [45]

Answer:

hypertext

Explanation:

Based on the information provided within the question it can be said that the type of computer system function being described is known as hypertext. This displays text to the computer display that references other literary documents for immediate access to them. These are documents with a specific relation to the text that is being displayed and also allows readers to comment and annotate what they read on the documents.

5 0
3 years ago
Do not use the scanner class or any other user input request. You application should be self-contained and run without user inpu
nikitadnepr [17]
يتريرينييننيخيوويميمسكيك
6 0
3 years ago
What is the advantage of using CSS?
Naily [24]

Answer:

c) It creates a better-structured document

Explanation:

The layout of a web page is better controlled. Style (CSS) kept separate from structure (HTML), means smaller file size. Reduced file size means reduced bandwidth, which means faster loading time.

3 0
4 years ago
Read 2 more answers
Other questions:
  • You are researching RAM for a computer you are building for a friend who will be using the system as a home office server for he
    6·1 answer
  • How can you recognize an unsecured wireless network?
    9·1 answer
  • The device used to connect a network to the internet is called a
    7·1 answer
  • A/an ________is a device used to protect computers against surges and spikes in power.
    14·1 answer
  • A class of cryptographic algorithms which requires two separate keys, one of which is secret (or private) and one of which is pu
    11·1 answer
  • Enthusiasm codehs 7.6.4 Write a function called add_enthusiasm that takes a string and returns that string in all uppercase with
    15·1 answer
  • True or False? You should never move an injured person.<br> True<br> False
    6·1 answer
  • Teknoloji ile ilgili 5 tane örnek yazabilir misiniz? Lütfen..
    12·1 answer
  • Write a function called printRange() that accepts two integers as arguments and prints the sequence of numbers between the two a
    10·1 answer
  • Suppose that you are given the following partial data segment. what value does idtype contain, in decimal?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!