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
Most search engines provide specific pages on which you can search for____ and
vazorg [7]

Answer: c

Explanation: a

7 0
3 years ago
Read 2 more answers
Which activity should be part of a long-term plan to positively affect your
STatiana [176]
D that is the answer but I need 20 words to send this text
5 0
3 years ago
A ______ object is used for displaying the results of a question based on stored data.
LekaFEV [45]

Answer:

B. report

Explanation:

Report is used to show the result of data base quires or stored data contain useful data use in decision making and analysis.

It is also called a report generator, it is a part of database management system that is used to extract information from one or more files and present it in specific format.

4 0
3 years ago
A reason improper use of netiquette can be risky is that users can
GaryK [48]

Answer:

A) Become vulnerable to online harassment

Explanation:

From my understanding, Netiquette refers to talking to other people, and being rude to others isn't gonna get you very far

4 0
3 years ago
Read 2 more answers
Which are popular mobile device accessories? Choose two answers.
son4ous [18]
Headsets and speakers
6 0
3 years ago
Read 2 more answers
Other questions:
  • What does the metric column in a routing table do?
    8·1 answer
  • Create a program asks a user for an odd positive integer. If the user gives and even number or a number that is negative it prom
    7·1 answer
  • What finger is used to key letter c
    12·2 answers
  • Write a program to assign distinct number between 1 and 200 into an int array of 100 elements in ascending order (you may reuse
    6·1 answer
  • What is a device driver
    10·1 answer
  • Can someone help me with these questions it's for drivers ed
    10·1 answer
  • Select the correct answer.
    15·1 answer
  • Define a function OutputValues() that takes two integer parameters and outputs all integers between the first and the second par
    15·1 answer
  • What steps can you take to secure your private information?.
    8·1 answer
  • What is the purpose of a web server? What is the purpose of a web browser?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!