rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
#------------------------------------------------------------------------------------------
# 주먹은 0, 보는 1, 가위는 2
your_choice = input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors. \n")
print("\n Your choice is...")
if your_choice == "0":
print(rock)
if your_choice == "1":
print(paper)
if your_choice == "2":
print(scissors)
# 컴퓨터도 같이 랜덤으로 0~2 숫자 반환하기
import random
computer_choice = random.randint(0, 2)
a = str(computer_choice)
print("\n computer's choice is...")
if a == "0":
print(rock)
if a == "1":
print(paper)
if a == "2":
print(scissors)
# 경우의 수 9가지 중 이기는 경우만 다 써주고 비기면 play again으로 가게 해주었다.
# 뭔가 더 좋은 방법이 있을 것 같은데 아쉽다.
if your_choice == "0" and a == "2":
print("You win")
if your_choice == "1" and a == "0":
print("You win")
if your_choice == "2" and a == "1":
print("You win")
if a == "0" and your_choice == "2":
print("You lose")
if a == "1" and your_choice == "0":
print("You lose")
if a == "2" and your_choice == "1":
print("You lose")
if your_choice == a:
print("play again.")
replit.com에서 돌리면 이렇게 나온다.
사용함수: random 모듈, input, print, if, else
아스키 아트 사이트: https://ascii.co.uk/
ASCII.co.uk - The home of all things ASCII
ascii.co.uk
여기서 필요한 아스키아트를 복사 붙여넣기 해서 사용한 것 같다.
수업 내용은 유데미 안젤라 강의 들으며 정리 중이다.
'개발공부 > Python' 카테고리의 다른 글
파이썬_딕셔너리(dictionary) (0) | 2023.03.14 |
---|---|
파이썬 pickle 함수 GPT한테 물어봤음 (0) | 2023.03.13 |
파이썬으로 밥 살 사람 구하기 (0) | 2023.01.19 |
파이썬으로 BMI 계산기 만들기 (0) | 2023.01.19 |
파이썬으로 밴드 이름 만들기 (0) | 2023.01.19 |