Boolean
Boolean
- 참인지 거짓인지를 다룸
- 참: True
- 거짓: False
Operatior
- and: 앞과 뒤 조건이 모두 True일 때 True
- or: 앞과 뒤 조건 중 하나라도 True이면 True
- not: not 뒤에 붙는 조건이 False일 때 True
- xor: 앞과 뒤 조건 중 하나만 True일 때 True
- in: 앞 변수가 뒤 조건에 포함되어 있으면 True
a | b | not a | not b | a and b | a or b | a and not b | not a and b | a xor b |
---|
True | True | False | False | True | True | False | Fasle | False |
False | False | True | True | False | True | False | False | False |
True | False | False | True | False | True | True | False | True |
False | True | True | False | False | False | False | True | True |
Relationship Operation
- >: 크다
- <: 작다
- >=: 크거나 같다
- <=: 작거나 같다
- ==: 같다
- !=: 다르다
Combinig Comparisions
- 파이썬은 다른 언어와 다르게 여러 Relationship Operation을 한 줄에 사용 가능
- 한 줄에 사용된 Relationship Operation은 and 관계로 엮여 있음
- ex) 1 < x < 5
- ex) 1 < 3 != True
- (1 < 3) and (1 < 3)의 결과 != True
Short-circuit Evaluation
- or operation의 앞 조건이 True라면 뒤 조건은 검토하지 않고 바로 True 반환
- and operation의 앞 조건이 False라면 뒤 조건은 검토하지 않고 바로 False 반환
Comparing Strings
- ASCII 코드 기반으로 character를 int로 치환하여 크기 비교
- 대문자 알파벳 -> 소문자 알파벳 순서
- 사전 순서