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
Leno4ka [110]
3 years ago
6

Randomly choose rock, paper, or scissors for the computer

Computers and Technology
1 answer:
Pepsi [2]3 years ago
8 0

import random

computer_choice = random.choice(["rock", "paper", "scissors"])

user_choice = input("rock, paper, or scissors? ")

if computer_choice == user_choice:

   print("It's a draw!")

elif user_choice == "rock" and computer_choice == "scissors":

   print("You win!")

elif user_choice == "paper" and computer_choice == "rock":

   print("You win!")

elif user_choice == "scissors" and computer_choice == "paper":

   print("You win!")

else:

   print("The computer wins!")

I wrote my code in python 3.8. I hope this helps.

You might be interested in
After Intel faced strong shifts in technologies, such as cloud services, social networking, mobile devices, etc., Intel realized
Crazy boy [7]

Answer:

d. Information governance board

Explanation:

In 2004 <em>Intel </em>was in need of a governance process as part of the company’s policy of <em>Intel’s Information Management (IMM)</em>. Such policies and governance were important in the corporation’s process in order to mirror the local laws as well as to reproduce Intel’s dynamic nature of its activities as a corporation. The <em>Information Governance Boards </em>were intended for every main data area of the company: <em>location, item, finance, customer, supplier, and worker</em>. Such Governance Boards would engage business people in the company to  embrace the stipulated policies also with the purpose of proptecting information.

8 0
3 years ago
A plan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedul
vesna_86 [32]

Answer:

A study routine

Explanation:

6 0
3 years ago
Read 2 more answers
Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: Enter a sentence or phrase: The only thing we
frosja888 [35]

Answer:

Explanation:

Section 1) Enter String and Output String

#include<iostream> //for input and output  

#include <string>  // for string  

using namespace std;  

int main()  

{  

   string sentense;

   cout<<"Enter a sentence or phrase: ";

  getline(cin,sentense);

  cout<<"You Entered :"<<sentense;

   return 0;  

}

Output

Enter a sentence or phrase: The only thing we have to fear is fear itself

You Entered :The only thing we have to fear is fear itself

Explanation

To get full sentence or phrase, we need to call getline function in string package which will get the overall entered string. cin will not get the whole sentence

Section 2) GetNumOfCharacters

int getNumberOfCharacters(string sentence){

int count =0;

for(int i=0; i<sentence.size(); i++){

 count++;

}

return count;

}

Explanation

As we have taken sentence as string in previous section, we need to count total number of characters in the input string. for that purpose we are iterating over all the characters within string through for loop. declaring count variable and initializing it with 0 and increment on every for loop iteration. at the end returning the count variable.

Section 3) Call the GetNumOfCharacters() in main method.

int main()  

{  

   string sentence;

   cout<<"Enter a sentence or phrase: ";

  getline(cin,sentence);

  cout<< getNumberOfCharacters(sentence);  //Here we call out method and output its value

   return 0;  

}

Explanation

In main method first we get the sentence with getline and then by using cout and calling the getNumberOfCharacters(sentence) function it will show the number of characters in string.

Output

Enter a sentence or phrase: The only thing we have to fear is fear itself

45

Section 4) Implement OutputWithoutWhitespace() function

#include<iostream> //for input and output  

#include <string>  // for string  

using namespace std;  

int getNumberOfCharacters(string sentence){

int count =0;

for(int i=0; i<sentence.size(); i++){

 count++;

}

return count;

}

void OutputWithoutWhitespace(string sentence){

string output="";

 for(int i=0; i<sentence.size(); i++){

 if(sentence[i]!=' ' && sentence[i] != '\t'){  // checking the tab and spaces

  output+=sentence[i];  //then add that into output string

 }

}

cout<< output;

}

int main()  

{  

   string sentence;

   cout<<"Enter a sentence or phrase: ";

  getline(cin,sentence);

  OutputWithoutWhitespace(sentence);

   return 0;  

}  

Code Explanation

In OutputWithoutWhitespace() function we get string as a parameter and iterating all the characters and if current iteration character from sentence string is not equal to tab('\t') and space then add that character into output string. After the loop is finished, output the result.

Output

Enter a sentence or phrase: The only thing we have to fear is fear itself       hello

Theonlythingwehavetofearisfearitselfhello

7 0
3 years ago
Advantages of machine language​
morpeh [17]

Machine Language is a language used to communicate with the Central Processing Unit (also known as the CPU)

6 0
3 years ago
Which control chart would you use to track rejections in a maintenance projeg when bug arrival pattern is not constant?
Mkey [24]

Answer:

<u>P chart</u> is the control chart that is used to monitor the rejection or acceptance whenever the bug arrival in pattern is not constant.

Explanation:

In case of only two possible outcomes, such as yes or no, accept or reject, P chart is used as control chart to track rejections. It is used to track rejections whenever the pattern of rejection is not constant. In this type of charts we collect the information from last few days to analyze and predict the next data to track rejections.

<u>For example:</u>

If we want to know that, in admission department of the university, how many students arrives to take admission in university, does not meet the qualification criteria each week. In this case there are only two options available either they meet criteria or not. In this case we use P chart with the help of previous week data to analyze the no. of students who are meeting qualification criteria in this week.

3 0
3 years ago
Other questions:
  • Which aspects of a project do project makers oversee?
    12·2 answers
  • true /falseCompression of entries in the term-document matrix can be used to reduce run-time storage and execution-time requirem
    10·1 answer
  • How to engage more underrepresented and under resourced students in stem programs?
    10·1 answer
  • Which of the following best meets the requirements of a strong password?
    5·2 answers
  • Physical activity such as sports or even a brisk walk can help reduce
    7·2 answers
  • 1. Consider a direct-mapped cache that can accommodate 8Mbytes from a main memory, that uses a 32-bit address and 32-byte blocks
    5·1 answer
  • Abrupt changes in road surface or the shape of the road may indicate
    15·2 answers
  • 17. Write a SELECT query for the palateE4 database that produces a result grid listing paintName, and a count of the occurrences
    12·1 answer
  • you type out a few sentences in an ms word file, and save it on your desktop. how is this data stored in the computer?
    14·1 answer
  • What kind of AR target category makes sense for a playing card with a picture on it?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!