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
Afina-wow [57]
4 years ago
10

Rock, Paper, Scissors! Write a program which let's the user play rock, paper, scissors against the computer. It should: Ask for

the user's name, and then use that name in output for scoring and messages Randomly generate the computer's choice ("rock", "paper" or "scissors") Ask the user to enter their choice ("rock", "paper" or "scissors") Display the computer's choice Compare the choices, then determine a winner: rock beats scissors paper beats rock scissors beat paper a tie results in a do-over until a winner is declared The winner (user or computer) gets a point After each round, display the total score for the user and the computer Ask if the user wants to play again If yes, then display another round of the game. Don't ask for the user's name again. If no, then display the total number of rounds played and the final score
Computers and Technology
1 answer:
sesenic [268]4 years ago
7 0

Answer:

import random

def getComputerChoice(num):

   if num == 1:

       return "rock"

   if num == 2:

       return "paper"

   return "scissor"

def main():

   name = input("Enter your name: ")

   rounds = 0

   com_wins = 0

   user_wins = 0

   while True:

       print("\n1.Rock")

       print("2.Paper")

       print("3.Scissor")

       user = int(input("Enter choice: "))

       rounds += 1

       while user<=0 or user>3:

          print("Invalid choice")

          user = int(input("Enter choice: "))

       computer_choice = random.randint(1,3)

       # This is for handling tie

       while computer_choice == user:

           computer_choice = random.randint(1,3)

       print("Computer has chosen ->",getComputerChoice(computer_choice))

       if (computer_choice==1 and user==2) or (computer_choice==2 and user==1):

           print("paper beats rock")

           winner = 2

       elif (computer_choice==3 and user==1) or (computer_choice==1 and user==3):

           print("rock beats scissor")

           winner = 1

       else:

           print("scissors beat paper")

           winner = 3

       if winner == user:

           print(name,"wins!!!")

           user_wins += 1

       else:

           print("Computer wins!!!")

           com_wins += 1

       play = input("Do you want to play again?(Y/N) ")

       if play == 'n' or play == 'N':

           break

   print("No of rounds played:",rounds)

   print("Computer won:", com_wins)

   print(name,"won:",user_wins)

main()

You might be interested in
Question 3 of 25 In computer science, what is a developer? A. A person who organizes all the details of a project B. An individu
notka56 [123]

Answer:

C. A person who builds and creates software applications

Explanation:

5 0
1 year ago
In social networking websites such as twitter, people leave narrow minded and subjective remarks and upload unacceptable videos.
koban [17]
The advice is That you Message Them To remind Them Those Type of posts are not appropriate if people on social Media say bad Things To you you block Them if people don’t Treat you nice
8 0
3 years ago
True False The explicit location always tells you where users are located when they type the query.
gregori [183]
It's true for only some users
7 0
3 years ago
Read 2 more answers
You work with alot of different documents in your internship with a software development company. What kinds of actions can you
Doss [256]

Answer:

Explanation:

Try as much as possible, to keep like files together in one folder. Even so there if you run into the hundreds or thousands, that is not going to be an easy thing do.

What ever you do, do clutter up your favorites bar, especially if your favorites spill over into where you have to push a button to get to them. Keep that bar open for what you really need on that bar. Mine has Brainly, Kitco, My Alberta Health, A graphing program, a second graphing program, Amazon, a scrabble word finder, and a couple of other things. It

If you can, try and keep your favorites to something that would be useless to anyone else. My favorites are worthless to anyone else. But I play a lot of scrabble related games.

7 0
3 years ago
What is phishing?
alexira [117]

Answer:

Phishing is the malicious act of keeping a false website or sending a false e-mail with the intent of masquerading as a trustworthy entity in order to acquire sensitive information such as usernames, passwords, and credit card details.

Therefore, the answer to the question is option C.

7 0
3 years ago
Other questions:
  • Which group on the Home Ribbon allows you to add shapes to a PowerPoint slide?
    10·2 answers
  • Okay I need help. In the first picture, the black glasses, that was my vision last year 52:17 135 and my vision now is 52:15 135
    5·1 answer
  • - The concept of communication competence suggests there is no single "ideal" or "effective" way to communicate in every situati
    6·2 answers
  • How do you recognize the brand name of a drug in the package insert?
    15·1 answer
  • A + B (AC (B +C’) D) = A + BD
    10·2 answers
  • You are seeking a way to store computer files so you have backup copies anywhere you go.? Which one of the secondary storage typ
    11·1 answer
  • Janice’s grandmother stayed at home and took care of her family while her grandfather worked. Today Janice lives on her own and
    15·2 answers
  • Which of the following best explains how devices and information can be susceptible to unauthorized access if weak passwords are
    9·1 answer
  • Make a jingle about basic of photo editing<br>pls answer me asap​
    10·1 answer
  • What are the steps for rearranging the layout of a form?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!