Python
[Python] AND, OR 연산하기
YEJI ⍢
2022. 9. 24. 15:21
728x90
AND
AND는 두 개의 조건이 있을 때 두 조건이 모두 참이여야지만 True입니다.
Condition 1 | Condition 2 | Result |
False | Flase | False |
True | False | False |
False | True | False |
True | True | True |
OR
OR은 두 개의 조건이 있을 때 한 조건만 참이면 결과가 True가 됩니다.
Condition 1 | Condition 2 | Result |
False | False | False |
True | False | True |
False | True | True |
True | True | True |
파이썬에서는 AND와 OR을 이렇게 사용할 수 있습니다.
print("0 and 0: ", 0 and 0)
print("1 and 0: ", 1 and 0)
print("1 and 1: ", 1 and 1)
print("0 or 0: ", 0 or 0)
print("1 or 0: ", 1 or 0)
print("1 or 1: ", 1 or 1)
Python에서 0은 flase, 1은 ture 입니다.
◡̈