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
VladimirAG [237]
3 years ago
13

Write a Python program stored in a file q1.py to play Rock-Paper-Scissors. In this game, two players count aloud to three, swing

ing their hand in a fist each time. When both players say three, the players throw one of three gestures: Rock beats scissors Scissors beats paper Paper beats rock Your task is to have a user play Rock-Paper-Scissors against a computer opponent that randomly picks a throw. You will ask the user how many points are required to win the game. The Rock-Paper-Scissors game is composed of rounds, where the winner of a round scores a single point. The user and computer play the game until the desired number of points to win the game is reached. Note: Within a round, if there is a tie (i.e., the user picks the same throw as the computer), prompt the user to throw again and generate a new throw for the computer. The computer and user continue throwing until there is a winner for the round.
Computers and Technology
1 answer:
never [62]3 years ago
8 0

Answer:

The program is as follows:

import random

print("Rock\nPaper\nScissors")

points = int(input("Points to win the game: "))

player_point = 0; computer_point = 0

while player_point != points and computer_point != points:

   computer = random.choice(['Rock', 'Paper', 'Scissors'])

   player = input('Choose: ')

   if player == computer:

       print('A tie - Both players chose '+player)

   elif (player.lower() == "Rock".lower() and computer.lower() == "Scissors".lower()) or (player.lower() == "Paper".lower() and computer.lower() == "Rock".lower()) or (player == "Scissors" and computer.lower() == "Paper".lower()):

       print('Player won! '+player +' beats '+computer)

       player_point+=1

   else:

       print('Computer won! '+computer+' beats '+player)

       computer_point+=1

print("Player:",player_point)

print("Computer:",computer_point)

Explanation:

This imports the random module

import random

This prints the three possible selections

print("Rock\nPaper\nScissors")

This gets input for the number of points to win

points = int(input("Points to win the game: "))

This initializes the player and the computer point to 0

player_point = 0; computer_point = 0

The following loop is repeated until the player or the computer gets to the winning point

while player_point != points and computer_point != points:

The computer makes selection

   computer = random.choice(['Rock', 'Paper', 'Scissors'])

The player enters his selection

   player = input('Choose: ')

If both selections are the same, then there is a tie

<em>    if player == computer: </em>

<em>        print('A tie - Both players chose '+player) </em>

If otherwise, further comparison is made

<em>    elif (player.lower() == "Rock".lower() and computer.lower() == "Scissors".lower()) or (player.lower() == "Paper".lower() and computer.lower() == "Rock".lower()) or (player == "Scissors" and computer.lower() == "Paper".lower()): </em>

If the player wins, then the player's point is incremented by 1

<em>        print('Player won! '+player +' beats '+computer) </em>

<em>        player_point+=1 </em>

If the computer wins, then the computer's point is incremented by 1

<em>    else: </em>

<em>        print('Computer won! '+computer+' beats '+player) </em>

<em>        computer_point+=1 </em>

At the end of the game, the player's and the computer's points are printed

<em>print("Player:",player_point) </em>

<em>print("Computer:",computer_point)</em>

You might be interested in
Which is a reason why an organization might get rid of its entire information processing unit?
Rasek [7]

Answer: To hire good IT staff

Explanation:

  The organization hire the good information technology staff so that it can help in the development and increase the productivity of the organization. The stronger employees means the company become more strong in terms of growth and productivity.  

The organization always maintain the quality of the employees so that it can help to increase the quality of the projects and services that is provided to the users.

The good information technology (IT) staff can deliver the good products and can also providing the relevant services  for the organization.

6 0
3 years ago
JAVA
Virty [35]

Answer:

Is in the provided screenshot

Explanation:

Get the last two characters and concatenate.

6 0
3 years ago
Savings accounts usually offer _________ interest rates than checking accounts. It is _________ to access your money in a saving
UkoKoshka [18]
<span>Checking account is another name for the current account. Checking account offers lower interest rate and it is easy to access you money in the checking account as compared to a savings account.
Thus, the answer is HIGHER and HARDER.</span>
8 0
4 years ago
Read 2 more answers
A print server uses a print ________ as a software holding area for jobs waiting to be printed.
vichka [17]

Answer:

spooler

Explanation:

A print server uses a print spooler as a software holding area for jobs waiting to be printed.

8 0
2 years ago
Read 2 more answers
Why aren’t white Wall auto tires as wide as they used to be?or why do most cars not have them at all?
Ivanshal [37]
Expence pretty much.

8 0
4 years ago
Other questions:
  • Write a program whose input is two integers and whose output is the two integers swapped. Place the values in an array, where x
    12·1 answer
  • You have connected thirteen pcs and laptops to a wireless network. to make your wlan more secure, what should you do to disallow
    11·1 answer
  • Write a program that lets a user enter N and that outputs N! (N factorial, meaning N*(N-1)*(N-2)*..\.\*2*1). Hint: Initialize a
    5·1 answer
  • Which of the following statements about computer graphics formats is true?
    14·1 answer
  • Which of the following is a bad password? Select one: a. The acronym for the title of your favorite song plus the year it came o
    11·1 answer
  • An attacker is intent on disturbing the communication by inserting bogus packets into the communications.
    9·1 answer
  • What is true about investments and risk
    14·1 answer
  • Write a python statement that print the number 1000
    6·1 answer
  • :|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|
    5·2 answers
  • Write a function named count_vowels that accepts two arguments: a string and an empty dictionary. The function should count the
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!