day3-3 python (중첩 if 문과 elif문)
2023. 2. 22. 07:22ㆍ개인적인 공부/Python
저번에 했던 if, else 문에서
print("Welcome to the rollercoaster!")
height = int(input("What is your height in cm? "))
if height >= 120:
print("You can ride the rollercoaster!")
else:
print("Sorry, you have to grow taller before you can ride.")
중첩 if 문
한번 더 선택의 갈림길이 주어진다.
# 중첩 if문
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 <= 18:
print("Your pay is $7")
else:
print("Your pay is $12")
else:
print("Sorry, you have to grow taller before you can ride.")
# 중첩 if문과 elif 문
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("Your pay is $5")
elif age <=18:
print("Your pay is $ 7")
else:
print("Your pay is $12")
else:
print("Sorry, you have to grow taller before you can ride.")
'개인적인 공부 > Python' 카테고리의 다른 글
day 3-5 python (윤년, Leap Year) (0) | 2023.02.22 |
---|---|
day 3-4 (BMI 2.0 Exercise) (0) | 2023.02.22 |
day 3-2 python (Odd or Even Exercise)(홀수 또는 짝수) (0) | 2023.02.22 |
day 3-1 python (if/else 및 조건 연산자를 통한 흐름 제어) (0) | 2023.02.21 |
day 2-8 Python (팁 계산기 tip-Calculator) (0) | 2023.02.21 |