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>