From e8c189df76faea700143ecc638b335d9fa1dcc29 Mon Sep 17 00:00:00 2001 From: Tanguy Deleplanque Date: Wed, 11 Jun 2025 23:19:45 +0200 Subject: [PATCH] day 4 --- 004/task.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/004/task.py b/004/task.py index def6fd8..9661a2c 100644 --- a/004/task.py +++ b/004/task.py @@ -1,8 +1,32 @@ +# import random + +# rand = random.randint(1, 2) + +# friends = ["Alice", "Bob", "Charlie", "David", "Emmanuel"] +# # lucky_friend = friends[random.randint(0, len(friends)-1)] +# lucky_friend = random.choice(friends) + +# print("Who pays the bill?") +# print(f"Iiiiiiiiiits {lucky_friend}!") + import random -rand = random.randint(1, 2) +moves = ["Rock", "Paper", "Scissors"] -if rand == 1: - print("Heads") +player_move = int(input("What do you choose? Type 0 for Rock, 1 for Paper and 2 for Scissors.\n")) +cpu_move = random.randint(0, 2) + +print(f"You played {moves[player_move]}") +print(f"CPU played {moves[cpu_move]}") + +player_vs_cpu = [player_move, cpu_move] + +if player_vs_cpu[0] == player_vs_cpu[1]: + print("Draw") +elif player_vs_cpu in [[2,1], [1, 0], [0,2]]: + print("You win!") else: - print("Tails") + print("You lose!") +# 2 beats 1 +# 1 beats 0 +# O beats 2 \ No newline at end of file