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
Thepotemich [5.8K]
3 years ago
15

PLZ HELP!!! I'm a beginner in coding!

Computers and Technology
1 answer:
Lina20 [59]3 years ago
4 0

import random

rock,paper,scissors = 1,2,3

choice = int(input("Please choose 1 2 or 3: "))

computer = random.randint(1,3)

player_won = False

draw = False

if choice == computer:

   draw = True

elif choice == 1 and computer == 3:

   player_won = True

elif choice == 2 and computer == 1:

   player_won = True

elif choice == 3 and computer == 2:

   player_won = True

if player_won:

   print("You won!")

elif not player_won and not draw:

   print("The computer won!")

else:

   print("It's a draw!")

First, I recommend importing at the beginning of your program. Also, you can combine all your same datatype variables in one line. You also need to cast your user choice to an integer so you can compare it with the computer's choice. I wrote the if, elif, and else statements using a boolean variable. I simply wrote all the possibilities that would result in the player winning and this would result in the player_won variable being true. If this is the case, we print to the console, "You won!"

You might be interested in
How would our life be without technology at school? please
insens350 [35]
IS THIS AN ESSAY PLEASE LET ME KNOW SO I CAN TYPE IT IN COMMENTS
5 0
3 years ago
Which feature of a blog helps to store and retrieve older posts?
Rashid [163]
Could it be archive posts? I'm not sure, but I believe it's archive posts.
8 0
3 years ago
Read 2 more answers
Copy the countdown function from Section 5.8 of your textbook. def countdown(n): if n <= 0: print('Blastoff!') else: print(n)
Lapatulllka [165]

Answer:

def countdown(n):

   if n <= 0:

       print('Blastoff!')

   else:

       print(n)

       countdown(n-1)

       

def countup(n):

   if n >= 0:

       print('Blastoff!')

   else:

       print(n)

       countup(n+1)

number = int(input("Enter a number: "))

if number >= 0:

   countdown(number)

elif number < 0:

   countup(number)

<u>Outputs:</u>

Enter a number: 3                                                                                                              

3                                                                                                                              

2                                                                                                                              

1                                                                                                                              

Blastoff!

Enter a number: -3                                                                                                              

-3                                                                                                                              

-2                                                                                                                              

-1                                                                                                                              

Blastoff!

Enter a number: 0

Blastoff!

For the input of zero, the countdown function is called.

Explanation:

Copy the countdown function

Create a function called countup that takes one parameter, n. The function counts up from n to 0. It will print the numbers from n to -1 and when it reaches 0, it will print "Blastoff!".

Ask the user to enter a number

Check if the number is greater than or equal to 0. If it is, call the countdown function. Otherwise, call the countup function.

4 0
3 years ago
The power on any voltage rail of the hard drive is calculated by multiplying _____. (a). Voltage X Current (b). Voltage X Watts
Papessa [141]

Answer:

(a). Voltage X Current

Explanation:

Power -

In the concept of physics , power is denoted by P ,

Power = Voltage * Current

Power = V * I

The unit is Ampere  *  Voltage

Power is defined as the rate of work done , i.e. , work divided by time .

Power = work / time .

Power is a scalar quantity .

The standard unit of power is Watt , which is denoted by W .

6 0
3 years ago
Instructions PhoneNumbersjava + 1 import java.util.*; 2 class PhoneNumbers 3 public static void main(String[] args) 4 //write co
gregori [183]

Answer:

What is the question?

8 0
4 years ago
Other questions:
  • Calculated fields can be entered in queries. What row should you type a calculated field in?
    13·1 answer
  • What is the primary purpose of a business plan? To file for incorporation To help you identify your goals and plan how you will
    6·1 answer
  • There are a number of classifications that can be applied to security controls.
    11·1 answer
  • When you start to type =av, what feature displays a list of functions and defined names?
    11·1 answer
  • Can someone help me with this one
    9·2 answers
  • Which operating system became obsolete with the arrival of more advanced graphical user interfaces
    12·1 answer
  • What is the function of control unit? in computer. <br>​
    8·1 answer
  • Hi who plays among us
    9·1 answer
  • Assume that x and y are boolean variables and have been properly initialized. !(x || y) || (x || y) The result of evaluating the
    10·1 answer
  • Please help it's on scratch coding !
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!