0% found this document useful (0 votes)
20 views1 page

CS106A - Springresh

The document is a Python program for a game of Rock, Paper, Scissors that plays against the computer over multiple rounds. The program takes the user's input for their choice each round, randomly generates the computer's choice, and determines if the user wins, loses, or ties based on the rules of the game. It tracks the number of rounds won by the user and prints the result of each individual round.

Uploaded by

Ihor Malinovskyi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

CS106A - Springresh

The document is a Python program for a game of Rock, Paper, Scissors that plays against the computer over multiple rounds. The program takes the user's input for their choice each round, randomly generates the computer's choice, and determines if the user wins, loses, or ties based on the rules of the game. It tracks the number of rounds won by the user and prints the result of each individual round.

Uploaded by

Ihor Malinovskyi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

14.06.

23, 01:02 CS106A | Spring

CS106A

Кінцеві підготовчі розчини

Повні програми

Камінь, Папір, Ножиці


import random

NUM_ROUNDS = 5

def main():
num_human_wins = 0

for i in range(NUM_ROUNDS):
user_choice = int(input("Your move (1, 2, or 3): "))
computer_choice = random.randint(1, 3)

if computer_choice == user_choice:
print("It's a tie!")
else:
if user_choice == 1:
if computer_choice == 3:
print("You win! Rock crushes scissors")
num_human_wins += 1
else:
print("You lose! Paper covers rock")

if user_choice == 3:
if computer_choice == 2:
print("You win! Scissors cuts paper")
num_human_wins += 1
else:
print("You lose! Rock crushes scissors")

if user_choice == 2:
if computer_choice == 1:
print("You win! Paper covers rock")
num human wins += 1
https://cs106a.stanford.edu/final-prep-soln 1/1

You might also like