[Python] 제어문

less than 1 minute read

[Python] 제어문

Inflearn Study

링크: https://www.inflearn.com/

  • 인프런에서 “파이썬 무료 강의 (기본편) - 6시간 뒤면 나도 개발자” 강의를 들으며 혼자 공부한 내용입니다.

if문

name = "아이언맨"
if name == "아이언맨":
    print("{0}, 커피가 준비되었습니다.".format(name))
else:
    print("{0}, 커피는 준비중입니다.".format(name))
  • if문의 기본 구조
    • if 조건

if-elif-else 예제

money = 10000
if money == 10000:
    print("{0}원으로 떡볶이 먹자".format(money))
elif money == 5000:
    print("{0}원으로 김밥 먹자".format(money))
else:
    print("{0}원밖에 없다 집에 가자".format(money))

Leave a comment