if 조건문
-
10. if 조건문으로 특정 조건일 때 코드 실행하기Python/Grammar 2022. 12. 2. 10:32
# 1. if 조건문 사용하기 if 조건문은 의사코드(pseudo code)의 일종이다. 의사코드란 실제 프로그래밍 언어가 아닌 사람의 언어로 프로그래밍 언어를 표현한 것이다. 예를 들어 'x = 10'이라는 파이썬 코드를 '변수 x에 10 할당'과 같이 한글로 의사코드를 표현할 수 있다. 1-1. if 조건문의 기본 형태와 실행 흐름 : if 조건문은 if 조건식 다음줄에 들여쓰기 후 조건식이 만족할 때 실행할 코드를 넣는다. 조건식이 만족할 때 실행할 코드를 if 본문(if body)이라고 부른다. 1-2. if 조건문을 사용할 때 주의할 점 들여쓰기 : if 조건문 다음줄부터 형성되는 코드블럭(if body) 안에서는 같은 깊이로 들여쓰기를 해줘야 한다. IDLE 파이썬 셸에서는 자동 들여쓰기가 되..