- if
# if
### 참, 거짓을 판단하는 조건 뒤에 ':'
### 조건에서 수행할 문장은 반드시 들여쓰기
### 조건 : <,>,==, and, or, not...
### 조건 : a in b, a not in b
if cond == 1:
print("one")
elif cond == 2:
print("two")
else:
print("else")
res = "one" if cond == 1 else "two" # 조건부 표현식 (한줄)
- for
# for
for a in arr:
print(a) #case1
for (first, last) in tuple_:
print(first + " " + last) #case2
for i in range(1,11):
print(i) #case3 (range)
- while
# while
while cond:
print("work")
if cond2:
break # 조건문 끝내기
if cond3:
continue # 조건문 처음으로
위키독스
온라인 책을 제작 공유하는 플랫폼 서비스
wikidocs.net
'Language > Python' 카테고리의 다른 글
[Python] 4_클래스 (0) | 2021.05.06 |
---|---|
[Python] 파이썬에서 음수의 "//" 연산(Floor Division) 이 다른 값을 가지는 이유 (0) | 2021.05.06 |
[Python] 파이썬에서 제곱 구하기-pow(), math.pow(), ** 의 차이 (0) | 2021.05.06 |
[Python] 3_함수 (0) | 2021.05.03 |
[Python] 1_자료형 (0) | 2021.04.29 |