day 4-7 python (가위 바위 보)

2023. 2. 24. 15:56개인적인 공부/Python

가위 바위 보

## 가위 바위 보
import random

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

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

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

choice = int(input("가위 바위 보 게임을 시작합니다. (숫자를 입력해주세요) : 0.바위 1.가위, 2.보 \n 당신의 선택은??: "))

if choice == 0 :
    print("당신의 선택은 : " + rock)

elif choice == 1:
    print("당신의 선택은 : " + scissors)

elif choice == 2:
    print("당신의 선택은 : " + paper)

##=======

## 컴퓨터 선택

map = [rock,scissors,paper]


computer_choice = random.randint(0,2)

if computer_choice == 0:
    print("컴퓨터의 선택은 : " + map[0])
elif computer_choice ==1:
    print("컴퓨터의 선택은 : " + map[1])
elif computer_choice ==2:
    print("컴퓨터의 선택은 : " + map[2])

## 승부

if choice == computer_choice:
    print("무승부")
elif choice != computer_choice:
    if choice == 0 and computer_choice == 1 :
        print ("당신의 승리")
    elif choice == 1 and computer_choice == 2 :
        print("당신의 승리")
    elif choice == 2 and computer_choice == 0 :
        print("당신의 승리")
    elif choice > 2 or choice < 0:
        print("잘못된 숫자 입력 당신의 패배!!")
    else:
        print("당신의 패배")

결과

 

 

 

가끔 가운데 손가락도 내민다.

 

'개인적인 공부 > Python' 카테고리의 다른 글

day 5-2 python (평균 키 구하기)  (0) 2023.02.27
day 5-1 for 반복문  (0) 2023.02.25
day 4-5 python indexError 및 중첩리스트  (0) 2023.02.24
랜덤 복습  (0) 2023.02.24
day 4-4 python (roulette, 룰렛)  (0) 2023.02.24