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
Marty uses a customized database to sort parts and track inventory. The customized database is an example of _____.
MakcuM [25]

cataloging, that is a term for it.

3 0
3 years ago
Which Azure service should you use to correlate events from multiple resources into a centralized repository?
Trava [24]

Answer:

D. Azure Log Analytics

Explanation:

The Azure service we can use when you have to correlate events from more than 1 sources into a repository which is centralized you have to use Azure Log Analytics.

it is a special surrounding for Azure monitor log data.Each workspace has their own repository and configuration.

Hence we conclude that the answer to this question is option D Azure Log Analytics.

6 0
3 years ago
Write a class named GasTank containing: An instance variable named amount of type double, initialized to 0. An instance variable
telo118 [61]

Answer:

The class GasTank is defined below

All the steps are briefed in comments

public class GasTank {

// instance variable initialization

private double amount = 0;

//declaring instance variable capacitance

private double capacity;

//constructor having parameter of type double

public GasTank(double i)

{

capacity = i;

}

// addGas method for increasing gas quantity.

public void addGas(double i)

//quantity of gas increased is added to the existing amount. If it becomes more than total capacity, amount is set to capacity

{ amount += i; if(amount > capacity) amount = capacity; / amount = amount < capacity ? amount+i : capacity;/ }

//useGas method having parameter of type double

public void useGas(double i)

//the parameter given is deducted from 0 and if results less than 0, remains equal to 0

{ amount = amount < 0 ? 0 : amount - i; }

//method isEmpty

public boolean isEmpty()

//Returns true if volume is less than 0.1 else false

{ return amount < 0.1 ? true : false; }

//method isFull

public boolean isFull()

//returns true if the value of amount is greater than  0.1 else false.

{ return amount > (capacity-0.1) ? true : false; }

//method getGasLeve

public double getGasLevel()

//Returns the value of amount instance variable

{ return amount; }

//method fillUp

public double fillUp()

//returns the difference between the capacity and the amount

{ double blah = capacity - amount; amount = capacity; return blah; }

}

5 0
4 years ago
Explain why decomposition will be used in creating the algorithm for the game including two dice.
RoseWind [281]
I saw this question while reviewing the notes in class
7 0
3 years ago
Self-disclosure is most likely to occur _____________.a.
Feliz [49]

The answer is..

C.  During one-on-one conversations

4 0
3 years ago
Read 2 more answers
Other questions:
  • Mara's presentation included essential information about the company's new safety procedures. She wanted to make
    13·2 answers
  • What are career resources?
    7·2 answers
  • How to build a communication network
    13·1 answer
  • A(n ________ is information that is passed to a function, and a(n ________ is information that is received by a function.
    15·1 answer
  • HELP WILL GIVE BRAINLIEST
    5·1 answer
  • Does anyone know how to connect a nintendo switch to a laptop?
    10·2 answers
  • URGENT: I need to add a while loop in this program but I don't know-how. I am also having trouble neatening some lines of code.
    15·1 answer
  • Plzzz help ya girl out due soon
    13·1 answer
  • You choose Option A for Overdraft Options. What would happen if you had $30 in your checking account and you tried to take out $
    12·1 answer
  • The most common technique for using an appropriate synchronization mechanism to serialize the accesses to prevent errors is to a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!