Site Tools


marc:linux:python:voorbeelden:rock_paper_scissors
rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

paper = '''
    _______
---'   ____)____
          ______)
          _______)
         _______)
---.__________)
'''

scissors = '''
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
'''

#Write your code below this line 👇
import random
# rock = 0
# paper = 1
# scissors = 2
player_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))
if player_choice == 0:
    print(rock)
elif player_choice == 1:
    print(paper)
elif player_choice ==2:
    print(scissors)
else:
    print("Your choice is not a valid choice!")
computer_choice = random.randint(0, 2)
print("Computer chose:\n")
if computer_choice == 0:
    print(rock)
elif computer_choice == 1:
    print(paper)
else:
    print(scissors)

if player_choice == computer_choice:
    print("It's a draw!")
elif player_choice == 0 and computer_choice == 1:
    print("Computer wins!")
elif player_choice == 0 and computer_choice == 2:
    print("You win!")
elif player_choice == 1 and computer_choice == 0:
    print("You win!")
elif player_choice == 1 and computer_choice == 2:
    print("Computer wins!")
elif player_choice == 2 and computer_choice == 0:
    print("Computer wins!")
elif player_choice == 2 and computer_choice == 1:
    print("You win!")
marc/linux/python/voorbeelden/rock_paper_scissors.txt · Last modified: (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki