[Python Bootcamp] Day3

Yul·2024년 9월 22일

Python Bootcamp

목록 보기
4/7
post-thumbnail

1. 배운 것

  • if Else
    • if 조건 : ~ else :
  • 숫자연산자 %를 이용한 even number, odd number 출력
  • elif
  • 다중 if
  • 논리 연산자
    • and, or, not

2. 프로젝트 : 보물섬

print('''
*******************************************************************************
          |                   |                  |                     |
 _________|________________.=""_;=.______________|_____________________|_______
|                   |  ,-"_,=""     `"=.|                  |
|___________________|__"=._o`"-._        `"=.______________|___________________
          |                `"=._o`"=._      _`"=._                     |
 _________|_____________________:=._o "=._."_.-="'"=.__________________|_______
|                   |    __.--" , ; `"=._o." ,-"""-._ ".   |
|___________________|_._"  ,. .` ` `` ,  `"-._"-._   ". '__|___________________
          |           |o`"=._` , "` `; .". ,  "-._"-._; ;              |
 _________|___________| ;`-.o`"=._; ." ` '`."\ ` . "-._ /_______________|_______
|                   | |o ;    `"-.o`"=._``  '` " ,__.--o;   |
|___________________|_| ;     (#) `-.o `"=.`_.--"_o.-; ;___|___________________
____/______/______/___|o;._    "      `".o|o_.--"    ;o;____/______/______/____
/______/______/______/_"=._o--._        ; | ;        ; ;/______/______/______/_
____/______/______/______/__"=._o--._   ;o|o;     _._;o;____/______/______/____
/______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_
____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____
/______/______/______/______/______/______/______/______/______/______/_____ /
*******************************************************************************
''')
print("Welcome to Treasure Island.")
print("Your mission is to find the treasure.")

q1=input("You're at a cross road. Where do you want to go? Type \"left\" or \"right\"")

if q1=="left":
    print("""You've come to a lake. 
          There is an island in the middle of the lake.""")
    q2=input("Type \"wait\" to wait for a boat. Type \"swim\" to swim across ")

    if q2=="wait":
        q3=input("""You Arrive at the island unharmed.\n
        There is a house with 3 doors.\n
        One red, One yellow, and one blue.\n
        Which colour do you choose?""")

        if q3=="red":
            print("It's a room full of fire. Game Over.")
        elif q3=="yellow":
            print("You found the treasure! You Win!")
        elif q3=="blue":
            print("You enter a room of beasts. Game Over.")
        else:
            print("You choose nothing")
    else:
        print("You get attacked by an angry trout. Game Over.")

else:
    print("You fell in to a hole. Game Over.")

결과창

profile
이것저것 공부하는 중

0개의 댓글