Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- singletone
- access modifier
- Wrapper class
- Up Casting
- 스트림
- identityHashCode
- 자바
- Java
- 파이참
- extends
- constructor
- 셔뱅
- finalize
- 깊은 복사
- 엔드포인트
- Inbound
- 내부클래스
- lambda
- parameter group
- arraycopy
- shebang
- dbeaver
- Stream
- pycharm
- down casting
- node.js
- generic programming
- 얕은 복사
- has-a
- public static final
Archives
- Today
- Total
٩(๑•̀o•́๑)و
if, elif, else 본문
# if
x = True
if x is False:
print('True입니다')
print('indentation')
print('no indentation')
====Result====
no indentation
x = True
if x is True:
pass
print('pass')
====Result====
pass
x = 34
if x>10:
print('x>10')
if x>20:
pass
if x>30:
print('x>30')
print('end')
====Result====
x>10
x>30
end
x = 25
# if x>10 and x<30 :
if 10 < x < 30: #simplify
print('10<x<30')
else:
print('10>x or 30<x')
====Result====
10<x<30
# else
x = 24
if x>30:
print('over 30')
else:
print('uner 30')
====Result====
uner 30
x = 4
y = x if x == 10 else 0
'''
# same as
if x == 10:
y = x
else:
y = 0
'''
print(y)
====Result====
0
if True:
print('참') # True는 참
else:
print('거짓')
if False:
print('참')
else:
print('거짓') # False는 거짓
if None:
print('참')
else:
print('거짓')
====Result====
참
거짓
거짓
if 0:
print(True)
else:
print(False)
if 1:
print(True)
else:
print(False)
if 0x1F: # hex
print(True)
else:
print(False)
if 0b1000: # binary
print(True)
else:
print(False)
if 0o71: # binary
print(True)
else:
print(False)
if 13.5:
print(True)
else:
print(False)
if 0.0:
print(True)
else:
print(False)
if 'hello':
print(True)
else:
print(False)
if '':
print(True)
else:
print(False)
if not '':
print(True)
else:
print(False)
====Result====
False
True
True
True
True
True
False
True
False
True
# elif
x = 25
if x>30:
print('x>30')
elif x>20:
print('x>20')
else:
print('x<20')
print('end')
====Result====
x>20
end
'Python' 카테고리의 다른 글
while (0) | 2020.09.09 |
---|---|
for (0) | 2020.09.09 |
dictionary (0) | 2020.09.09 |
sequence types - slice (0) | 2020.09.08 |
sequence types (0) | 2020.09.08 |