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
Stuck on where to go with this one.
garri49 [273]

1

7

6 I think how many do you have to answer

8 0
3 years ago
What do you mean by computer ethics?​
STALIN [3.7K]

Answer:

Computer ethics is a field of applied ethics that addresses ethical issues in the use, design and management of information technology and in the formulation of ethical policies for its regulation in society.

3 0
2 years ago
Unicode is a world standard to represent _________________
horsena [70]

Answer:

characters.

Explanation:

We need to represent characters in binary format so that they can be stored in computer memory. Earlier, ASCII (American Standard Code for Information Interchange) representation was commonly used for english characters. But ASCII was found to be insufficient for representing multilingual and special characters.Unicode character representation was developed to overcome this limitation.

8 0
3 years ago
In general, font size for software-generated presentation slides should be no smaller than __________ points.
hjlf
The smallest you should have is PROBABLY 24 points.  Anything below that is going to strain the audience's eyes!  However, the title text can be a bit bigger, around 36 and then for text anything around 24-26 should work!
5 0
3 years ago
Add me on Pokemon go, my trainer code is 5584 3300 5313
evablogger [386]

Answer:

no want it

Explanation:

7 0
3 years ago
Other questions:
  • What is a googleplex?
    7·1 answer
  • Apple's macOS and Microsoft Windows are examples of ________ software. utility application communication operating system
    13·1 answer
  • As Assembly language code runs on a CPU invoking functions and using the stack, it is clear that CPU registers are
    8·1 answer
  • A host device needs to send a large video file across the network while providing data communication to other users. Which featu
    8·1 answer
  • Which type of word processing programs enables users to include illustrations within the program?
    10·2 answers
  • Given a MxN matrix.Print the elements in odd rows from left to right and the elements in even rows from right to left.(Java or C
    11·1 answer
  • When the function below is called with 1 dependent and $400 as grossPay, what value is returned?
    13·1 answer
  • A file named "dogs.txt" exists and has 60 lines of data. You open the file with the following line of code.
    5·1 answer
  • LAB: Parsing dates in M/D/Y format
    5·1 answer
  • Question 1 of 10 Which type of information systems personnel are involved in organizing information so that users can access it
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!