Command & Development/Python

[Python] 가위바위보 게임

Richard.Ryu 2024. 1. 8. 14:30
반응형
rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

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

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

import random

print("What do you choose? Type 0 for Rack, 1 for Paper or 2 for Scissors.")

user_random = int(input())
computer_random = random.randint(0, 2)

if user_random == 0:
    print("You choose Rack")
    print(rock)
    if computer_random == 1:
        print("Computer choose Paper")
        print(paper)
        print("You lose")
    elif computer_random == 2:
        print("computer choose Scissors")
        print(scissors)
        print("You win")
    else:
        print("Computer choose Rack")
        print(rock)
        print("Draw")
elif user_random == 1:
    print("You choose Paper")
    print(paper)
    if computer_random == 1:
        print("Computer choose Paper")
        print(paper)
        print("Draw")
    elif computer_random == 2:
        print("computer choose Scissors")
        print(scissors)
        print("computer win")
    else:
        print("Computer choose Rack")
        print(rock)
        print("You win")
elif user_random == 2:
    print("You choose Scissors")
    print(scissors)
    if computer_random == 1:
        print("Computer choose Paper")
        print(paper)
        print("You win")
    elif computer_random == 2:
        print("computer choose Scissors")
        print(scissors)
        print("Draw")
    else:
        print("Computer choose Rack")
        print(rock)
        print("You lose")
        
  
  
  #Result
  #What do you choose? Type 0 for Rack, 1 for Paper or 2 for Scissors.
  #0
  #You choose Rack

#    _______
#---'   ____)
#      (_____)
#      (_____)
#      (____)
#---.__(___)

#computer choose Scissors

#    _______
#---'   ____)____
#          ______)
#       __________)
#      (____)
#---.__(___)

#You win

rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

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

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

#Write your code below this line 👇
import random

print("What do you choose? Type 0 for Rack, 1 for Paper or 2 for Scissors.")

user_random = int(input())
computer_random = random.randint(0, 2)

if user_random == 0:
    print("You choose Rack")
    print(rock)
    if computer_random == 1:
        print("Computer choose Paper")
        print(paper)
        print("You lose")
    elif computer_random == 2:
        print("computer choose Scissors")
        print(scissors)
        print("You win")
    else:
        print("Computer choose Rack")
        print(rock)
        print("Draw")
elif user_random == 1:
    print("You choose Paper")
    print(paper)
    if computer_random == 1:
        print("Computer choose Paper")
        print(paper)
        print("Draw")
    elif computer_random == 2:
        print("computer choose Scissors")
        print(scissors)
        print("computer win")
    else:
        print("Computer choose Rack")
        print(rock)
        print("You win")
elif user_random == 2:
    print("You choose Scissors")
    print(scissors)
    if computer_random == 1:
        print("Computer choose Paper")
        print(paper)
        print("You win")
    elif computer_random == 2:
        print("computer choose Scissors")
        print(scissors)
        print("Draw")
    else:
        print("Computer choose Rack")
        print(rock)
        print("You lose")

반응형

'Command & Development > Python' 카테고리의 다른 글

[Python] instagram 자동 좋아요  (0) 2024.08.20
[Python] Lotto 번호 생성  (0) 2023.03.29
Python - 4  (0) 2022.05.12
Python - 3  (0) 2022.05.11
Python - 2  (0) 2022.05.10