1️⃣ 제어문의 개념

구분 설명
제어문(Control Statement) 프로그램의 실행 순서를 바꾸는 명령
종류 조건문(if), 반복문(while, for), 기타 제어문(break, continue)

🧩 프로그램은 위에서 아래로 순차적으로 실행되지만,

제어문을 이용하면 조건에 따라 실행 흐름을 바꾸거나 반복할 수 있음.


2️⃣ 조건문 (Conditional Statements)

🔹 기본 형태: if

score = int(input("정수 입력: "))
if score >= 90:
    print("성적 : A")
    print("장학금 수여")


🔹 if - else

score = int(input("점수: "))
if score >= 90:
    print("pass")
else:
    print("fail")

한 줄 표현식 (삼항 연산자)

res = 'pass' if score >= 90 else 'fail'
print(res)

🔹 복합 조건문 예제: 윤년 판단

year = int(input("연도 입력: "))
if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
    print(year, "is a leap year")
else:
    print(year, "is not a leap year")

조건 논리