Boolean logic & truth tables
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Boolean values
- A Boolean value is either
TrueorFalse. - A condition such as
age >= 18produces a Boolean. - Computers build everything from these two values.
한국어
부울리안 값(Boolean values)
- 부울리안(Boolean) 값은either
True또는False입니다. age >= 18와 같은 조건은 부울리안을 생성합니다.- 컴퓨터는 이 두 가지 값으로 모든 것을 구성합니다.
English
AND, OR, NOT
andis True only when both sides are True.oris True when at least one side is True.notflips True to False, and False to True.
한국어
AND, OR, NOT
and는 양쪽 모두 True일 때만 True입니다.or는 최소 하나가 True일 때 True입니다.not는 True를 False로, False를 True로 반전합니다.
print(True and False) # False
print(True or False) # True
print(not True) # False
English
A truth table
- A truth table lists every possible input and its output.
- Two inputs (A, B) give four rows: 00, 01, 10, 11.
한국어
진리표(Truth table)
- 진리표(truth table) 는 가능한 모든 입력과 그에 대한 출력을 나열합니다.
- 두 개의 입력(A, B)은 네 줄을 생성합니다: 00, 01, 10, 11.
Explore · 탐색하기
Truth table — try every input
and is true only when both are true; or when at least one is.
English
Build a truth table with loops
- A nested loop over
False, Truewalks through all the combinations.
한국어
루프를 사용하여 진리표 만들기
False, True에 대한 중첩 루프(nested loop)는 모든 조합을遍历합니다.
for a in [False, True]:
for b in [False, True]:
print(a, b, a and b)
English
More gates: NAND, NOR, XOR
- NAND is
not (a and b); NOR isnot (a or b). - XOR is True when the inputs are different:
a != b.
한국어
기타 게이트: NAND, NOR, XOR
- NAND은
not (a and b); NOR은not (a or b)입니다. - XOR은 입력이 다를 때 True입니다:
a != b.
English
In the exam: logic gates
- Know the gates NOT, AND, OR, NAND, NOR, XOR and their truth tables.
한국어
시험 준비: 논리 게이트
- NOT, AND, OR, NAND, NOR, XOR 게이트와 Their 진리표를 알고 있어야 합니다.
X ← A AND B
Y ← NOT (A OR B)
English
Common mistakes
ANDis true only when both inputs are true;ORis true when at least one is.NOTflips the value.- A truth table lists every combination of the inputs.
한국어
흔한 실수
AND는 두 입력이 모두 True일 때만 참이며;OR는 최소 하나만 True일 때 참입니다.NOT는 값을 반전합니다.- 진리표는 입력의 모든 조합을 나열합니다.
English
Now you try
- Each function returns the gate's Boolean output.
- Press Check answer to test your code.
한국어
이제 직접 해보기
- 각 함수는 해당 게이트의 부울리안 출력을 반환합니다.
- Answer 확인 버튼을 눌러 코드를 테스트하세요.
Write AND_gate(a, b) that returns True only when both inputs are True.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.
Write XOR_gate(a, b) that returns True when the two inputs are different, and False when they are the same.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.
Write NAND_gate(a, b) that gives the opposite of AND: True unless both inputs are True. Use not (a and b).
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.