if condition:
do this
else:
do this
water_level = 50
if water_level >80 :
print("Drain water")
else:
print("Continue")
print("Welcome to the rollercoaster!")
height = int(input("What is your height in cm? "))
if height >=120: #120보다 크거나 같다면!
print("You can ride the rollercoaster!")
else:
print("Sorry, you have to grow taller before you can ride.")
number = int(input("Which number do you want to check? "))
if number % 2 == 0:
print("This is an even number")
else :
print("This is an odd number.")
if condition:
if another condition:
do this
else:
do this
else:
do this
print("Welcome to the rollercoaster!")
height = int(input("What is your height in cm? "))
if height >=120:
print("You can ride the rollercoaster!")
age = int(input("What is your age?")
if age < 12:
print("Please pay $5.")
elif age <= 18:
print("Please pay $7.")
else:
print("Please pay $12.")
else:
print("Sorry, you have to grow taller before you can ride.")
height = float(input("enter your height in m: "))
weight = float(input("enter your weight in kg: "))
bmi = weight/height**2
bmi = float("{:.2f}".format(bmi))
if bmi < 18.5 :
print(f"Your BMI is {bmi}, you are slightly underweight.")
elif bmi < 25:
print(f"Your BMI is {bmi}, you have a normal weight")
elif bmi < 30:
print(f"Your BMI is {bmi}, you are slightly overweight.")
elif bmi < 35:
print(f"Your BMI is {bmi}, you are obse.")
else:
print(f"Your BMI is {bmi}, you are clinically obse.")
year = int(input("Which year do you want to check? "))
if year % 4 == 0 :
if year % 100 == 0:
if year % 400 == 0:
print("leap year")
else:
print("not leap year")
else:
print("leap year")
else:
print("not leap year")
if condition 1:
do A
if condition 2:
do B
if condition 3:
do C
-모두 참이라면 세 가지가 모두 실행됨.
print("Welcome to the rollercoaster!")
height = int(input("What is your height in cm? "))
bill = 0
if height >= 120:
print("You can ride the rollercoaster!")
age = int(input("What is your age? "))
if age < 12:
bill = 5
print("Child tickets are $5.")
elif age <= 18:
bill = 7
print("Youth tickets are $7.")
else:
bill = 12
print("Adult tickets are $12.")
wants_photo = input("Do you want a photo taken? Y or N. ")
if wants_photo == "Y":
bill += 3
print(f"Your final bill is ${bill}")
else:
print("Sorry, you have to grow taller before you can ride.")
print("Welcome to Python Pizza Deliveries!")
size = input("What size pizza do you want? S, M, or L ")
add_pepperoni = input("Do you want pepperoni? Y or N ")
extra_cheese = input("Do you want extra cheese? Y or N ")
bill = 0
if size == "S":
bill += 15
elif size == "M":
bill += 20
else:
bill += 25
if add_pepperoni == "Y":
if size == "S":
bill += 2
else:
bill+= 3
if extra_cheese == "Y":
bill+= 1
print(f"Your total pay amount is $ {bill}.")
if condition1 & condition2 & condition3:
do this
else:
do this
print("Welcome to the rollercoaster!")
height = int(input("What is your height in cm? "))
bill = 0
if height >= 120:
print("You can ride the rollercoaster!")
age = int(input("What is your age? "))
if age < 12:
bill = 5
print("Child tickets are $5.")
elif age <= 18:
bill = 7
print("Youth tickets are $7.")
elif age >= 45 and age <= 55:
print("Everything is going to be ok. Have a free ride on us!")
else:
bill = 12
print("Adult tickets are $12.")
wants_photo = input("Do you want a photo taken? Y or N. ")
if wants_photo == "Y":
bill += 3
print(f"Your final bill is ${bill}")
else:
print("Sorry, you have to grow taller before you can ride.")
print("Welcome to the Love Calculator!")
name1 = input("What is your name? \n")
name2 = input("What is their name? \n")
name = (name1+ name2).lower()
t_count = name.count('t')
r_count= name.count('r')
u_count= name.count('u')
e_count= name.count('e')
l_count= name.count('l')
o_count= name.count('o')
v_count= name.count('v')
total_front = str(t_count + r_count + u_count + e_count)
total_back = str(l_count + o_count + v_count + e_count)
total_score = int(total_front + total_back)
if t(otal_score <10) or (total_score>90):
print(f"Your score is {total_score}, you go together like coke and mentos.")
elif 40 <= total_score <= 50 :
print(f"Your score is {total_score}, you are alright together.")
else:
print(f"Your score is {total_score}.")
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.")
print("Welcome to Treasure Island.\n Your mission is to find the treasure.\n")
first_choice= input("You\'re at a cross road. Where do you want to go? Type \"left\" or \"right\" \n")
first_choice_as_lower = first_choice.lower()
if first_choice_as_lower == "left":
second_choice = (input("you\'ve come to a lake. There is an island in the middle of the lake. Type \"wait\" to wait for a boad. Type \"swim\" to swim across. \n")).lower()
if second_choice == "wait":
last_choice = (input("You arrive at the island unharmed. There is a house with 3 doors. One red, one yellow and one blue. Which colur do you choose? \n")).lower()
if last_choice == "red":
print("It\'s a room full of fire. Game Over.")
elif last_choice == "blue":
print("You enter a room of beasts. Game Over.")
elif last_choice == "yellow":
print("You found the treasure! You Win!")
else:
print("You chose a door that doesn't exist. Game Over.")
else:
print("You ge attacked by an angry trout. Game Over.")
else:
print("You fell into a hole. Game Over.")