NAVER AI Tech/Python & AI math
5. (Python) 조건문, 반복문
코딩소비
2023. 11. 7. 14:09
비교연산자
- x < y, x <= y, x > y, x >= y
- x == y, x is y
- s != y, x is not y
if x > y:
print('True')
else:
print('False')
논리 키워드 : and, or, not, **all(), **any()
- all([True, True, True, False]) -> False
- any([True, True, True, False]) -> True
**삼항 연산자
value = 12
is_even = True if value%2 == 0 else False
is even -> True 반환
반복문 : for, while
for _ in range(4):
print(_)
for i in range(0,4,2): # 2를 간격으로 출력
print(i)
for i in range(1,10,-1): # 거꾸로 출력
print(i)
while x > y:
print(x,y)
if x == y:
break
else:
continue
break, continue : 반복문 제어
디버깅 : Error 메세지 분석.
- Google, stackoverflow에서 검색하면서 고치기~