Due 11/11 at 11:59pm
Rock, Paper, Scissors is a classic game. But what if you played multiple rounds and kept score? In this project, you will write a program that plays multiple rounds against the computer, keeps track of wins and losses, and crowns a champion!
Your program must meet the following specifications:
random module to pick the computer’s moveget_winner that compares the player’s move and computer’s move and returns 'player', 'computer', or 'tie'while or for loop to play multiple rounds (at least 3)get_winner to determine the round winnerFor example, after 3 rounds, your program might print:
=== ROUND 1 ===
You chose: rock
Computer chose: scissors
You win! 🎉
=== ROUND 2 ===
You chose: paper
Computer chose: paper
It's a tie!
=== ROUND 3 ===
You chose: scissors
Computer chose: rock
Computer wins!
=== FINAL SCORE ===
You: 1 win
Computer: 1 win
Ties: 1
The random module lets you pick random values. Import it at the top and use random.choice() to pick from a list:
import random
moves = ['rock', 'paper', 'scissors']
computer_move = random.choice(moves)
print(computer_move) # could be any of the three
Here is a starting point. Fill in the TODO comments to meet the specifications above!
import random
def get_winner(player, computer):
"""Compare moves and return the winner."""
# TODO: return 'player', 'computer', or 'tie'
pass
# Game setup
moves = ['rock', 'paper', 'scissors']
player_wins = 0
computer_wins = 0
ties = 0
# Play multiple rounds
# TODO: use a while or for loop to play at least 3 rounds
# Get player input
player_move = input("Choose rock, paper, or scissors: ").lower()
# Get computer move
computer_move = random.choice(moves)
# Determine winner
# TODO: call get_winner() and store the result
# Print round results
# TODO: print what each player chose and who won
# Update scores
# TODO: increment the appropriate counter
# Print final leaderboard
# TODO: print player wins, computer wins, and ties
When you’re happy with your tournament, upload the .py file to ThinkWave.