Dr. Angela의 100일 간의 코드 Python 부트캠프 중 03일차

03일에는 if/else 및 중첩된 if와 같은 조건문을 사용하여 Create your own Adventure Game을 만들었습니다. 그 과정에서 bmi 계산기를 만드는 것과 입력된 연도가 윤년인지 여부를 결정하는 프로그램을 만드는 것과 같은 연습을 했습니다.

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.") 

stage1 = input("You're at a crossroad. 
Where do you want to go? Type \"left\" or \"right\"").lower()

if stage1 == "left":
  stage2 = input("You've come to a lake. There is an 
island in the middle of the lake. Type \"wait\" 
to wait for a boat. Type \"swim\" to swim across.").lower()
  if(stage2 == "wait"):
    stage3 = input("""You arrive at the island unharmed. 
There is a house with 3 doors. One red, one yellow 
and one blue. Which colour do you choose?""").lower()
    if(stage3 == "red"):
      print("It's a room full of fire. Game Over.")
    elif(stage3 == "yellow"):
      print("You Win!")
    elif(stage3 == "blue"):
      print("You enter a room of beasts. Game Over.")
    else: 
      print("GAMEOVER")
  elif(stage2 == "swim"):
    print("You get attacked by an angry trout. Game Over.")
  else: 
    print("You get attacked by an angry trout. Game Over.")
elif(stage1 == "right"): 
  print("You fell into a hole. Game Over.")
else: 
  print("You fell into a hole. Game Over.")





순서도:


산출:

좋은 웹페이지 즐겨찾기