CS106A - Springresh
CS106A - Springresh
CS106A
Повні програми
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