소연의_개발일지
article thumbnail
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

여기서 필요한 아스키아트를 복사 붙여넣기 해서 사용한 것 같다.

수업 내용은 유데미 안젤라 강의 들으며 정리 중이다. 

profile

소연의_개발일지

@ssoyxon

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!