Logic gates have certain rules that determine what the outputs are with respect to the inputs
b. When we are analyzing a logic gate, we can visualize all of the possible outputs by making a truth table. A truth table shows the output for all possible inputs.
For example, if we have a gate that returns
1 if and only if both the inputs
1, we can create the truth table:
Each row represents an observation of output depending on the values of
b. So the first row shows that when
0, the output will be
When we make a truth table, we want to represent the entire universe of possibilities. This means that we want every combination of inputs to be represented. For 2 variables (
b), we will need 4 rows to represent all of these combinations.
In Python, and many other programming languages,
1 evaluates to be
0 evaluates to be false.
Let’s suppose we have a gate that returns
1 if either
1, but not if they are both
Here is the truth table that corresponds to the gate, with the third row missing:
Create the variables
val3 and assign them to the values that will complete the truth table for this gate.