day 4
This commit is contained in:
32
004/task.py
32
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
|
||||
Reference in New Issue
Block a user