Lesson Plan
Course Title: Computer Programming
Session Title: Boolean Logic
Lesson Duration: 2-3 hours
Performance Objective:
Upon completion of this assignment, the student will be able to apply Boolean logic in
problem solving and identify logic terms and explain the logic operators.
Specific Objectives:
Recognize and explain the function of Boolean logical operators: NOT, AND, OR
Generate truth tables for logic operators
Given a logic statement, identify the correct locations on Venn diagrams
Match shaded Venn diagrams to logic statements
Given logical conditions in sample code, predict the outcome
Apply Boolean logic to create a decision-making structure
Identify logic terms and explain the logic operators
Preparation
TEKS Correlations: 130.276(c)
1.E – solve problems and think critically
4.B – identify input and output requirements
4.C – identify system processing requirements
6.B – perform a logical design
6.C – use algorithmic concepts
6.D – identify constraints
7.E – compare computed results with anticipated results to determine the reasonableness of
the solutions
PRESENTATIONInstructor/Trainer
References:
Content Developer Knowledge
Java Software Solutions for AP Computer Science, by Lewis, Loftus, & Cocking, copyright
2004, Pearson Education, Inc.
Introduction to Computer Science using Java, by Liberty, Quirk & Weiss, copyright 2005,
Glencoe McGraw-Hill
Instructional Aids:
Lab File: LogicObservation.java
Handout: Observing Boolean Logic & KEY
Lab File: LogicObservation2.java
Handout: Observing Boolean Logic2 & KEY
Presentation: Boolean Logic
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
1
Handout: Boolean Logic & KEY
Lab File : EasyUsingLogic.java & EasyUsingLogicKEY.java
Handout: Boolean Logic Review & KEY
Handout: Boolean Logic Quiz A & B & KEYS
Handout: Boolean Logic Test and Re-Test & KEYS
Presentation: Digital Gates
Handout: Gates and Boolean Expressions & KEY
Lab File: GetUp.java
Materials Needed:
• Copies of instructional aides
• Pen or pencil
Equipment Needed: Each student will need access to a computer with Java installed
Learner
The learner should have understanding of simple Java code, including system output and IF
statements.
Introduction
MI
Introduction (LSI Quadrant I):
The instructor begins a group discussion about practical decisions that students
make on their own, by having students list various choices and decisions that they
make throughout the day, beginning with the choice of whether or not to get out of
bed. Have students also identify what factors they base their decisions on. In
programming, the factors that are evaluated to make a decision are known as the
‘condition.’ Have students critique hypothetical situations in which people make good
and bad decisions. Have students summarize characteristics of effective decision
making.
Have students come to the board to draw a simple decision tree that has branches
for each option that can be chosen. For example, the question ‘should I get up?’ has
two possible options: the ‘yes’ branch leads to other possible questions, like ‘should I
eat breakfast?;’ the ‘no’ branch leads right back to the condition that existed prior to
asking the question ‘should I get up?’
Outline
MI
Outline (LSI Quadrant II):
Instructor Notes:
The instructor presents the ‘Boolean Logic’
Presentation. Students follow along using the
‘Boolean Logic Guided Notes.’ The instructor can
pause at any point to expand the discussion or
clarify concepts.
The Presentation and guided
notes can also be used by
students who were absent
and trying to catch up. It can
also be used as a review.
Terms & Concepts presented:
• Boolean background
The ‘Boolean Logic Guided
Notes KEY’ helps to assess
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
2
•
•
•
•
•
•
how well the student followed
and comprehended the
presentation.
Boolean Operators (AND, OR, NOT)
Order of operations
Venn diagrams
Truth Tables
Evaluating Boolean expressions
Using Boolean expressions in Java
The lab handout ‘Observing Boolean Logic’ uses the
Java file ‘LogicObservation.java,’ and is intended for
students to observe and analyze the function of
Boolean expressions in Java code.
Students observe and analyze the following:
• Declaration of Boolean variables
• Evaluation of Boolean conditions
• Truth table values as they occur in Java code for
NOT, OR, AND
• Combinations of Boolean variable values
Students can work alone or
in pairs to complete the lab,
but each should turn in their
own paper. The questions on
the paper match sections in
the Java file.
Students can work alone or
in pairs to complete the lab,
but each should turn in their
own paper.
Observation labs do not require much code
modification. Students observe and analyze the
operation of existing code.
The lab handout ‘Observing Boolean Logic 2’ uses
the Java file ‘LogicObservation2.java,’ and is
intended for students to observe and analyze the
function of Boolean expressions in Java code.
Students observe and analyze the following:
• Relational operators
• Setting Boolean variables and values
• Using Boolean variables
Application
MI
Guided Practice (LSI Quadrant III):
The lab file ‘LogicPractice.java’ contains commented instructions and code samples.
The student copies and pastes sample code, making minor modifications to build
confidence in using Boolean logic in Java. Students may work in pairs, but each
student should complete their own lab file.
Successful completion of the lab is evident when the student’s code prints different
messages, depending on the age and gender answers given during prompts in the
program. It is possible to have more than one message.
The four cases of the lab are as follows:
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
3
•
•
•
•
MI
If the age is between 14 and 18, the message should say “in High School”
If the age is more than 15 and the gender is male, the message should say “You
should be shaving”
If the gender is female and the age is more than 21, the message should say
“You get an insurance break”
If the age is below 5 or above 55, the message should say “You get a discount”
Independent Practice (LSI Quadrant III):
The lab file ‘EasyUsingLogic.java’ contains commented instructions and code
samples. The student can use samples in the code, or from previous labs, to
complete objectives in the instructions. At this point students should be able to work
without a lab partner.
This lab simulates ticket price calculations at a ticket booth. Successful completions
of the lab are evident when the student’s code prints different messages, depending
on the age, row, and coupon answers given during prompts in the program. It is
possible to have more than one message.
The cases of the lab are as follows:
• If the age is below 12, the row is not the front row, and there is no coupon; the
message should say “$5”
• If the age is below 12, the row is not the front row, and there is a coupon; the
message should say “$3”
• If the age is below 12, and the row is the front row; the message should say “$8”
whether or not there is a coupon.
• If the age is 12 or more, the row is not the front row, and there is no coupon; the
message should say “$10”
• If the age is 12 or more, the row is not the front row, and there is a coupon; the
message should say “$8”
• If the age is 12 or more, and the row is the front row; the message should say
“$12”, whether or not there is a coupon.
Summary
MI
Review (LSI Quadrants I and IV):
The worksheet ‘Logic Review’ helps students confirm their understanding of truth
tables, Venn diagrams, and Boolean expressions. After grading have a group
discussion to explain each problem.
Evaluation
MI
Informal Assessment (LSI Quadrant III):
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
4
The students show their completed labs to the teacher, who may also ask pointed
questions about how certain sections of the code work.
The amount of help students need in completing a lab may indicate their degree of
understanding and application of the material.
MI
Formal Assessment (LSI Quadrant III, IV):
Logic Quiz & Logic Test let students demonstrate mastery of Boolean expressions,
Venn diagrams, truth tables, and the application of Boolean logic in simple Java
code.
Extension
MI
Extension/Enrichment (LSI Quadrant IV):
Have students complete the ‘GetUp.java’ lab file. Students create a series of
questions to help them decide whether or not to get up in the morning. Questions
could include such factors as ‘is it a week day?’ or ‘is it earlier than 7:00am?’ The
code will also need to contain Boolean decision-making to indicate if the student will,
in fact, get up, based on the answers provided. Students may copy blocks of code
from previous labs and modify it as needed.
Successful completion of the lab is evident when the student’s code prints different
messages, depending on the three questions that are designed by the student.
Testing the students’ code will requiring several attempts using different answers.
Additional Enrichment includes presenting the Presentation ‘Digital Gates’ which
explains the connection between Boolean logic and digital schematic, including the
following concepts:
• How True and False relate to actual voltages in electronics
• Recognizing Gate symbols as they are used in schematics
• An explanation of how each of the basic gates works
• The abbreviation of the NOT gate symbol as a circle
• Schematics can be converted to Boolean expressions
Students use information from the Presentation to complete the handout ‘Gates and
Boolean Expressions.’
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
5
Icon
MI
Verbal/
Linguistic
Logical/
Mathematical
Visual/Spatial
Musical/
Rhythmic
Bodily/
Kinesthetic
Intrapersonal
Interpersonal
Naturalist
Existentialist
Teaching Strategies
Personal Development
Strategies
Lecture, discussion, journal
writing, cooperative learning,
word origins
Reading, highlighting, outlining,
teaching others, reciting information
Problem solving, number
games, critical thinking,
classifying and organizing,
Socratic questioning
Mind-mapping, reflective
time, graphic organizers,
color-coding systems,
drawings, designs, video,
DVD, charts, maps
Use music, compose songs
or raps, use musical
language or metaphors
Organizing material logically, explaining
things sequentially, finding patterns,
developing systems, outlining, charting,
graphing, analyzing information
Developing graphic organizers, mindmapping, charting, graphing, organizing
with color, mental imagery (drawing in
the mind’s eye)
Use manipulatives, hand
signals, pantomime, real life
situations, puzzles and board
games, activities, roleplaying, action problems
Reflective teaching,
interviews, reflective listening,
KWL charts
Cooperative learning, roleplaying, group brainstorming,
cross-cultural interactions
Natural objects as
manipulatives and as
background for learning
Socratic questions, real life
situations, global
problems/questions
Creating rhythms out of words, creating
rhythms with instruments, playing an
instrument, putting words to existing
songs
Moving while learning, pacing while
reciting, acting out scripts of material,
designing games, moving fingers under
words while reading
Reflecting on personal meaning of
information, studying in quiet settings,
imagining experiments, visualizing
information, journaling
Studying in a group, discussing
information, using flash cards with
other, teaching others
Connecting with nature, forming study
groups with like minded people
Considering personal relationship to
larger context
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
6
Name: _______________________ Date: ________________ Period: ________
Observing Boolean Logic
Objective: Observe and analyze the function of Boolean logic operators and the outcome of
Boolean statements.
Instructions: Follow the directions below as you run the program LogicObservation.java.
Record your observations and analysis below.
#1 BOOLEAN VALUES
1. Look at the statement above section #1 where the Boolean variables are declared.
What is the value of ‘b’? [ true / false / a / b ]
2. When the variable ‘a’ is put in System.out.println(), what is printed? [ true / false / a
/ b ]
3. When any variable is put in System.out.println(), what is printed? [ the name of the
variable / the value of the variable / cannot be determined ]
#2 BOOLEAN CONDITIONS
4. In the statement ‘ if (a) ‘ , the condition evaluates to the value [ true / false / a / b ].
5. The statement after ‘ if (b) ‘ , [ does / does not ] execute because the value of ‘b’ is [
true / false ].
6. The statement after ‘ if (false) ‘ does not print because…
a. the value ‘false’ is not valid for a condition.
b. you must put a Boolean variable in the condition.
c. the condition evaluates to false.
d. it is not a valid statement.
7. If the value of an if statement’s condition evaluates to true, then the statement that
follows [ will / will not ] execute.
#3 NOT
8. The expression ‘ !a ‘ evaluates to… [ a / true / false / 0 ].
9. The expression ‘ !false ‘ evaluates to… [ a / true / false / 0 ].
10. The NOT operator ‘!’ does which of the following?
a. Makes a true value false and a false value true
b. Makes the value one less than it was
c. Shows the value instead of the name
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
7
#4 AND
11. ( true && true ) evaluates to [ true / false ].
12. ( true && false ) evaluates to [ true / false ].
13. ( false && true ) evaluates to [ true / false ].
14. ( false && false ) evaluates to [ true / false ].
15. When a true and a false are AND’ed together, like ( true && false) or (false && true), it [
does / does not ] matter if the true value is first.
16. The statement (a && b) is the same as which one?
a. ( true && false )
b. ( true && true )
c. ( false && false )
#5 OR
17. ( true || true ) evaluates to [ true / false ].
18. ( true || false ) evaluates to [ true / false ].
19. ( false || true ) evaluates to [ true / false ].
20. ( false || false ) evaluates to [ true / false ].
21. The statement (a || b) is the same as which one?
a. ( true || false )
b. ( true || true )
c. ( false || false)
#6 COMBINING BOOLEAN OPERATORS
22. ( a && !b ) evaluates to [ true / false ].
23. ( !a && b ) evaluates to [ true / false ].
24. ( false || !false ) evaluates to [ true / false ].
25. ( !!!false ) evaluates to [ true / false ].
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
8
Name: _______________________ Date: ________________ Period: ________
Observing Boolean Logic KEY
Objective: Observe and analyze the function of Boolean logic operators and the outcome of
Boolean statements.
Instructions: Follow the directions below as you run the program LogicObservation.java.
Record your observations and analysis below.
#1 BOOLEAN VALUES
1. Look at the statement above section #1 where the Boolean variables are declared.
What is the value of ‘b’? [ true / false / a / b ]
2. When the variable ‘a’ is put in System.out.println(), what is printed? [ true / false / a
/ b ]
3. When any variable is put in System.out.println(), what is printed? [ the name of the
variable / the value of the variable / cannot be determined ]
#2 BOOLEAN CONDITIONS
4. In the statement ‘ if (a) ‘ , the condition evaluates to the value [ true / false / a / b ].
5. The statement after ‘ if (b) ‘ , [ does / does not ] execute because the value of ‘b’ is [
true / false ].
6. The statement after ‘ if (false) ‘ does not print because…
a. the value ‘false’ is not valid for a condition.
b. you must put a boolean variable in the condition.
c. the condition evaluates to false.
d. it is not a valid statement.
7. If the value of an if statement’s condition evaluates to true, then the statement that
follows [ will / will not ] execute.
#3 NOT
8. The expression ‘ !a ‘ evaluates to… [ a / true / false / 0 ].
9. The expression ‘ !false ‘ evaluates to… [ a / true / false / 0 ].
10. The NOT operator ‘!’ does which of the following?
a. Makes a true value false and a false value true
b. Makes the value one less than it was
c. Shows the value instead of the name
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
9
#4 AND
11. ( true && true ) evaluates to [ true / false ].
12. ( true && false ) evaluates to [ true / false ].
13. ( false && true ) evaluates to [ true / false ].
14. ( false && false ) evaluates to [ true / false ].
15. When a true and a false are AND’ed together, like ( true && false) or (false && true), it [
does / does not ] matter if the true value is first.
16. The statement (a && b) is the same as which one?
a. ( true && false )
b. ( true && true )
c. ( false && false )
#5 OR
17. ( true || true ) evaluates to [ true / false ].
18. ( true || false ) evaluates to [ true / false ].
19. ( false || true ) evaluates to [ true / false ].
20. ( false || false ) evaluates to [ true / false ].
21. The statement (a || b) is the same as which one?
a. ( true || false )
b. ( true || true )
c. ( false || false)
#6 COMBINING BOOLEAN OPERATORS
22. ( a && !b ) evaluates to [ true / false ].
23. ( !a && b ) evaluates to [ true / false ].
24. ( false || !false ) evaluates to [ true / false ].
25. ( !!!false ) evaluates to [ true / false ].
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
10
Name: _________________________ Date: ____________________ Period: _____
Observing Boolean Logic2
Objective: Observe and analyze the function of Boolean logic operators and relational
operators.
Instructions: Follow the directions below as you run the program LogicObservation2.java.
Record your observations and analysis below. Circle all correct answers for each question.
#1 RELATIONAL OPERATORS
1. In the if statement, if ( age > 12 && age <20), which of the following values of age would
make the condition true? There may be more than one. [ 21 / 12 / 15 / 6 / no value
could make the condition true ]
2. When the condition above is evaluated, which are evaluated first, the relational
operators ( > < ) or the Boolean operator ( && )? [ relational / Boolean ]
3. In the if statement, if ( age < 16 || age > 72), which of the following values of age would
make the condition true? There may be more than one. [ 15 / 25 / 78 / no value
could make the condition true ]
4. In the if statement if ( !(age <18) ) , the condition is true if age is [ less than 18, greater
than 18 ].
#2 SETTING BOOLEAN VARIABLES
5. Look at the code in section #2. If the user enters a 13 for the ‘gender’ variable, then the
value of isMale will be [ 13 / 1 / 0 / true / false ].
6. Look at the code in section #2. In general, what happens?
a. The user enters a Boolean value that may change the original value of a Boolean
variable.
b. The user enters a numeric value that may change the original value of a Boolean
variable.
7. Look at the code in section #2. If the user enters a 1 for the ‘hungry’ variable, then the
value of isHungry will be [ -1 / 1 / 0 / true / false ].
8. Look at the code in section #2. If the user enters a 2 for the ‘senior’ variable, then the
value of isSenior will be [ 2 / 1 / 0 / true / false ].
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
11
9. Look at the code in section #2. Which of the following statements are true about the
Boolean variables? There may be more than one.
a. They are declared and initialized inside of the if statements.
b. They are declared and initialized outside of the if statements.
c. The only way they can have a value assigned is if the condition of the if
statement is true; otherwise they will not have a value.
#3 USING BOOLEAN VARIABLES
10. The if statement if (isSenior && age < 18) will still evaluate to true, even if isSenior is
false, as long as age is less than 18. [ true / false ]
11. The if statement if (!isMale && age < 12) only evaluates to true for girls under the age
of 12. [ true / false ]
12. The if statement if (isHungry && isSenior) evaluates to true for juniors who are not
hungry. [ true / false ]
13. The if statement if (age > 16 || !isSenior) evaluates to true for seniors who are 17. [ true
/ false ]
14. The if statement if (!isMale && isSenior) only evaluates to true for female seniors. [
true / false ]
15. Write your own if condition that prints “Lunch” either for girls or non-seniors.
if (
){
System.out.println(“Lunch”);
}
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
12
Name: _________________________ Date: ____________________ Period: _____
Observing Boolean Logic2 KEY
Objective: Observe and analyze the function of Boolean logic operators and relational
operators.
Instructions: Follow the directions below as you run the program LogicObservation2.java.
Record your observations and analysis below. Circle all correct answers for each question.
#1 RELATIONAL OPERATORS
1. In the if statement, if ( age > 12 && age <20), which of the following values of age would
make the condition true? There may be more than one. [ 21 / 12 / 15 / 6 / no value
could make the condition true ]
2. When the condition above is evaluated, which are evaluated first, the relational
operators ( > < ) or the Boolean operator ( && )? [ relational / boolean ]
3. In the if statement, if ( age < 16 || age > 72), which of the following values of age would
make the condition true? There may be more than one. [ 15 / 25 / 78 / no value
could make the condition true ]
4. In the if statement, if ( !(age <18) ) , the condition is true if age is [ less than 18, greater
than 18 ].
#2 SETTING BOOLEAN VARIABLES
5. Look at the code in section #2. If the user enters a 13 for the ‘gender’ variable, then the
value of isMale will be [ 13 / 1 / 0 / true / false ].
6. Look at the code in section #2. In general, what happens?
a. The user enters a Boolean value that may change the original value of a Boolean
variable.
b. The user enters a numeric value that may change the original value of a
Boolean variable.
7. Look at the code in section #2. If the user enters a 1 for the ‘hungry’ variable, then the
value of isHungry will be [ -1 / 1 / 0 / true / false ].
8. Look at the code in section #2. If the user enters a 2 for the ‘senior’ variable, then the
value of isSenior will be [ 2 / 1 / 0 / true / false ].
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
13
9. Look at the code in section #2. Which of the following statements are true about the
Boolean variables? There may be more than one.
a. They are declared and initialized inside of the if statements.
b. They are declared and initialized outside of the if statements.
c. The only way they can have a value assigned is if the condition of the if
statement is true; otherwise they will not have a value.
#3 USING BOOLEAN VARIABLES
10. The if statement if (isSenior && age < 18) will still evaluate to true, even if isSenior is
false, as long as age is less than 18. [ true / false ]
11. The if statement if (!isMale && age < 12) only evaluates to true for girls under the age
of 12. [ true / false ]
12. The if statement if (isHungry && isSenior) evaluates to true for juniors who are not
hungry. [ true / false ]
13. The if statement if (age > 16 || !isSenior) evaluates to true for seniors who are 17. [
true / false ]
14. The if statement if (!isMale && isSenior) only evaluates to true for female seniors. [
true / false ]
15. Write your own if condition that prints “Lunch” either for girls or non-seniors.
if ( ! isMale || ! isSenior) {
System.out.println(“Lunch”);
}
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
14
Name: _________________________ Date: ____________________ Period: _____
Guided Notes: Boolean Logic
Objective: Become familiar with Boolean operators, logic statements and Venn Diagrams.
Instructions: Answer the questions below as you view the presentation.
1. Which would be true for a brown-eyed girl? [ Brown-eyed AND male / Brown-eyed OR
male ]
2. Write the Java Boolean operators for the following
a. AND
___
b. OR
___
c. NOT
___
3. Which of the following is true for a short red-head? [ !Tall && Blonde / !(tall && blonde)
]
4. Write numbers in the space to indicate the order in which they should be considered.
a. _ _ _ AND &&
b. _ _ _ NOT !
c. _ _ _ OR ||
d. _ _ _ PARENTHESIS ( )
5. Color in the following Venn diagrams.
A || B
A && B
!A
!A && B
6. Complete your own truth tables below
A
B
A&&B
T
T
T
F
F
T
F
F
A
T
T
F
F
B
T
F
T
F
A||B
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
15
A
T
T
F
F
A
T
T
F
F
B
T
F
T
F
!B
B
T
F
T
F
A || !B
7. If blonde=true, what is (!blonde)? [ blonde / true / false ]
8. What generalization can you make about the AND (&&) truth table? There may be more
than one correct statement.
a. If any variable is TRUE, the result will be TRUE.
b. If any variable is FALSE, the result will FALSE.
c. All variables must be FALSE to make the result FALSE.
d. All variables must be TRUE to make the result TRUE.
9. What generalization can you make about the OR (||) truth table? There may be more
than one correct statement.
a. If any variable is TRUE, the result will be TRUE.
b. If any variable is FALSE, the result will FALSE.
c. All variables must be FALSE to make the result FALSE.
d. All variables must be TRUE to make the result TRUE.
10. Shade in the Venn Diagrams
A || ! B
A && !B
!A && !B
11. What do the values need to be to make the Boolean expression “x && !y”, evaluate to
True?
a. x = true, y = true
b. x = false, y = true
c. x = true, y = false
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
16
Name: _________________________ Date: ____________________ Period: _____
Guide Notes: Boolean Logic KEY
Objective: Become familiar with Boolean operators, logic statements and Venn Diagrams.
Instructions: Answer the questions below as you view the presentation.
1. Which would be true for a brown-eyed girl? [ Brown-eyed AND male / Brown-eyed OR
male ]
2. Write the Java Boolean operators for the following
a. AND
&&
b. OR
||
c. NOT
!
3. Which of the following is true for a short red-head? [ !Tall && Blonde / !(tall && blonde)
]
4. Write numbers in the space to indicate the order in which they should be considered.
a. _ 3 _ _ AND &&
b. _ 2 _ _ NOT !
c. _ 4 _ _ OR ||
d. _ 1 _ _ PARENTHESIS ( )
5. Color in the following Venn diagrams.
A || B
A && B
!A
!A && B
6. Complete your own truth tables below
A
T
T
F
F
A
T
T
B
T
F
T
F
B
T
F
A&&B
T
F
F
F
A||B
T
T
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
17
F
F
T
F
T
F
A
T
T
F
F
B
T
F
T
F
!B
F
T
F
T
A
T
T
F
F
B
T
F
T
F
A || !B
T
T
F
T
7. If blonde=true, what is (!blonde)? [ blonde / true / false ]
8. What generalization can you make about the AND (&&) truth table? There may be more
than one correct statement.
a. If any variable is TRUE, the result will be TRUE.
b. If any variable is FALSE, the result will FALSE.
c. All variables must be FALSE to make the result FALSE.
d. All variables must be TRUE to make the result TRUE.
9. What generalization can you make about the OR (||) truth table? There may be more
than one correct statement.
a. If any variable is TRUE, the result will be TRUE.
b. If any variable is FALSE, the result will FALSE.
c. All variables must be FALSE to make the result FALSE.
d. All variables must be TRUE to make the result TRUE.
10. Shade in the Venn Diagrams
A || ! B
A && !B
!A && !B
11. What do the values need to be to make the Boolean expression “x && !y”, evaluate to
True?
a. x = true, y = true
b. x = false, y = true
c. x = true, y = false
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
18
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Review
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answers for each question.
The following are Boolean variables used to describe a sandwich: P is for pepperoni, C is for
cheese, M is for Mushrooms.
1. A pizza with either pepperoni or mushrooms is…( P || M ) / ( P && M ) / ( !P || !C ) / (
P || C )
2. A pizza with neither pepperoni nor cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / ( P
|| C )
3. A pizza with mushrooms but no cheese is…( M && ! C) / ( !M && !C ) / ( M || !C ) / !(
M || C )
4. Shade the Venn diagram below for ( !A || B )
5. Shade the Venn diagram below for ( A && !B)
boolean x = false;
int age = 7;
while ( !x && age > 2) {
if ( age = = 4 )
x = !x;
age --;
}
6. When the loop above finishes, the value of age will be? ____
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
19
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
A && B
A
True
True
False
False
B
True
False
True
False
A || B
A
True
True
False
False
B
True
False
True
False
!A || B
A
True
True
False
False
B
True
False
True
False
!A && ! B
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
20
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Review KEY
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answers for each question.
The following are Boolean variables used to describe a sandwich: P is for pepperoni, C is for
cheese, M is for Mushrooms
1. A pizza with either pepperoni or mushrooms is…( P || M ) / ( P && M ) / ( !P || !C ) / (
P || C )
2. A pizza with neither pepperoni nor cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / ( P
|| C )
3. A pizza with mushrooms but no cheese is…( M && ! C) / ( !M && !C ) / ( M || !C ) / !(
M || C )
4. Shade the Venn diagram below for ( !A || B )
5. Shade the Venn diagram below for ( A && !B)
boolean x = false;
int age = 7;
while ( !x && age > 2) {
if ( age = = 4 )
x = !x;
age --;
}
6. When the loop above finishes, the value of age will be? _3__
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
21
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
A && B
True
False
False
False
A
True
True
False
False
B
True
False
True
False
A || B
True
True
True
False
A
True
True
False
False
B
True
False
True
False
!A || B
True
False
True
True
A
True
True
False
False
B
True
False
True
False
!A && ! B
False
False
False
True
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
22
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Quiz A
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answer for each question.
The following are Boolean variables used to describe a sandwich: P is for pickles, B is for
Bacon, C is for cheese, M is for mustard.
1. A sandwich with either pickles or cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / ( P ||
C )
2. A sandwich with neither pickles nor cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / !(
P || C )
3. A sandwich with mustard but no cheese is…( M && ! C) / ( !M && !C ) / ( M || !C ) /
!( M || C )
4. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
5. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
6. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
23
7. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
boolean x = true;
int age = 1;
while ( x && age < 7) {
if ( age = = 4 )
x = !x;
age ++;
}
8. When the loop above finishes, the value of age will be [ 1 / 4 / 5 / 7 / 8 ]
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
A && B
A
True
True
False
False
B
True
False
True
False
A || B
A
True
True
False
False
B
True
False
True
False
!A || B
A
True
True
False
False
B
True
False
True
False
A && ! B
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
24
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Quiz A KEY
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answer for each question.
The following are Boolean variables used to describe a sandwich: P is for pickles, B is for
Bacon, C is for cheese, M is for mustard.
1. A sandwich with either pickles or cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / ( P ||
C )
2. A sandwich with neither pickles nor cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / !(
P || C )
3. A sandwich with mustard but no cheese is…( M && ! C) / ( !M && !C ) / ( M || !C ) /
!( M || C )
4. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
5. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
6. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
25
7. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
boolean x = true;
int age = 1;
while ( x && age < 7) {
if ( age = = 4 )
x = !x;
age ++;
}
8. When the loop above finishes, the value of age will be [ 1 / 4 / 5 / 7 / 8 ]
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
A && B
True
False
False
False
A
True
True
False
False
B
True
False
True
False
A || B
True
True
True
False
A
True
True
False
False
B
True
False
True
False
!A || B
True
False
True
True
A
True
True
False
False
B
True
False
True
False
A && ! B
False
True
False
False
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
26
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Quiz B
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answer for each question.
boolean x = true;
int age = 1;
while ( x && age < 7) {
if ( age = = 4 )
x = !x;
age ++;
}
1. When the loop above finishes, the value of age will be [ 1 / 4 / 5 / 7 / 8 ]
The following are Boolean variables used to describe a sandwich: P is for pickles, B is for
Bacon, C is for cheese, M is for mustard.
2. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
3. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
4. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
5. A sandwich with either pickles or cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / ( P ||
C )
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
27
6. A sandwich with neither pickles nor cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / !(
P || C )
7. A sandwich with mustard but no cheese is…( M && ! C) / ( !M && !C ) / ( M || !C ) /
!( M || C )
8. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
A || B
A
True
True
False
False
B
True
False
True
False
A && B
A
True
True
False
False
B
True
False
True
False
A || !B
A
True
True
False
False
B
True
False
True
False
!A && B
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
28
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Quiz B KEY
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answer for each question.
boolean x = true;
int age = 1;
while ( x && age < 7) {
if ( age = = 4 )
x = !x;
age ++;
}
1. When the loop above finishes, the value of age will be [ 1 / 4 / 5 / 7 / 8 ]
The following are Boolean variables used to describe a sandwich: P is for pickles, B is for
Bacon, C is for cheese, M is for mustard.
2. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
3. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
4. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
5. A sandwich with either pickles or cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / ( P ||
C )
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
29
6. A sandwich with neither pickles nor cheese is…( B || C ) / ( P && C ) / ( !P || !C ) / !(
P || C )
7. A sandwich with mustard but no cheese is…( M && ! C) / ( !M && !C ) / ( M || !C ) /
!( M || C )
8. Circle the correct expression for the Venn diagram above. ( A && B) / ( A || B ) / ( !A ||
B ) / ( ! A && B ) / ( A && !B) / ( A || ! B) / ( !B)
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
A || B
True
True
True
False
A
True
True
False
False
B
True
False
True
False
A && B
True
False
False
False
A
True
True
False
False
B
True
False
True
False
A || !B
True
True
False
True
A
True
True
False
False
B
True
False
True
False
!A && B
False
False
True
False
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
30
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Test
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answers for each question.
The following are Boolean variables used to describe a crowd: H = people with hats, M = males,
P= people with phones
1. People with either phones or hats. ( H && P ) / ( P && H ) / ( P || H )
2. Women who do not have phones. ( F && !P ) / ( !M && !P ) / ( !M || ! P )
3. Men without hats. ( M || !H) / ( M && !H) / ( !H || M )
Match the descriptions to the Venn diagrams by writing the number of the description in
the blank above the diagram.
4. Women who have either hats or phones
5. Women who have hats and phones
6. Men who have both hats and phones
7. Men who have phones
8. Women who have no men
9. Men who have phones but do not have hats
10. Men who have hats
11. Men who have hats but do not have phones
12. Men who don’t have neither phones nor hats
_______
_______
_______
_______
_______
______
_______
_______
________
_______
________
_______
______
_______
Match the logic expressions below with the Venn diagrams above by writing the number
of the expression in the blank below the diagram.
13. M && (P && !H)
14. M && P
15. M && (H && !P)
16. M && P && H
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
31
17. M && H
18. !M && (H || P)
19. !M && (H && P)
boolean a = true, b = false, c = true;
if ( !b ){
System.out.print(b);
b = !b;
}
if (b && a){
c = !a;
System.out.print(a);
}
if (a || !c) {
b = !b;
System.out.print(b);
}
20. When the code above runs, it will print [ truetruetrue / truefalsetrue / truetruefalse /
falsefalsefalse / falsetruefalse / falsetruetrue
21. When the code above finishes running, the value of a is [ true / false ]
22. When the code above finishes running, the value of b is [ true / false ]
23. When the code above finishes running, the value of c is [ true / false ]
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
A && B
A
True
True
False
False
B
True
False
True
False
!!!A || B
A
True
True
False
False
B
True
False
True
False
!A && ! B
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
32
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Test KEY
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answer for each question.
The following are Boolean variables used to describe a crowd: H = people with hats, M = males,
P= people with phones
1. People with either phones or hats ( H && P ) / ( P && H ) / ( P || H )
2. Women who do not have phones ( F && !P ) / ( !M && !P ) / ( !M || ! P )
3. Men without hats ( M || !H) / ( M && !H) / ( !H || M )
Match the descriptions to the Venn diagrams by writing the number of the description in
the blank above the diagram.
4. Women who have either hats or phones.
5. Women who have hats and phones
6. Men who have both hats and phones.
7. Men who have phones
8. Women who have no men
9. Men who have phones but do not have hats
10. Men who have hats
11. Men who have hats but do not have phones
12. Men who don’t have neither phones nor hats
_ _11 _
_ 15_ _
_ _10 _
_ _9 _
_ _7 _
_ _17 _
_ 13_ _
_ _14 _
_ _4_ _
__6_
_ 18_ _
_ 16_ _
_ _5_ _
_ 19_ _
Match the logic expressions below with the venn diagrams above by writing the number
of the expression in the blank below the diagram.
13. M && (P && !H)
14. M && P
15. M && (H && !P)
16. M && P && H
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
33
17. M && H
18. !M && (H || P)
19. !M && (H && P)
boolean a = true, b = false, c = true;
if ( !b ){
System.out.print(b);
b = !b;
}
if (b && a){
c = !a;
System.out.print(a);
}
if (a || !c) {
b = !b;
System.out.print(b);
}
20. When the code above runs, it will print [ truetruetrue / truefalsetrue / truetruefalse /
falsefalsefalse / falsetruefalse / falsetruetrue
21. When the code above finishes running, the value of a is [ true / false ]
22. When the code above finishes running, the value of b is [ true / false ]
23. When the code above finishes running, the value of c is [ true / false ]
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
A && B
True
False
False
False
A
True
True
False
False
B
True
False
True
False
!!!A || B
True
False
True
True
A
True
True
False
False
B
True
False
True
False
!A && ! B
False
False
False
True
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
34
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Re-Test
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answers for each question.
The following are Boolean variables used to describe a crowd: G = Girls, I = ID badge, U = Untucked shirt
1.
Boys with un-tucked shirts ( B && U ) / ( !G && U ) / ( !G || U )
2. Girls with tucked-in shirts and ID badges ( G && !U && I ) / ( G || !U || I ) / ( !G && !U &&
!I )
3. Boys with no ID badge ( !G || !I ) / ( !G && I ) / ( !G && !I )
Match the descriptions to the Venn diagrams by writing the number of the description in
the blank above the diagram.
4. Girls who have ID, and their shirts are tucked-in
5. People with ID and un-tucked shirts
6. Boys who have un-tucked shirts and IDs
7. Girls who have neither IDs, nor un-tucked shirts
8. Girls who have IDs
9. Boys who have either IDs or un-tucked shirts
10. Girls who have either ID or un-tucked shirts
11. Girls who don’t have ID, but they do have un-tucked shirts
12. Girls who have ID and un-tucked shirts
______
______
______
______
_______
_______
_______
______
______
______
______
______
_______
_______
Match the logic expressions below with the Venn diagrams above by writing the number
of the expression in the blank below the diagram.
13. G && ( I || U )
14. !G && ( I && U )
15. ( I && U )
16. G && ( I && ! U )
17. G && ( I && U )
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
35
18. G && ( ! I && ! U )
19. G && I
boolean a = false, b = false, c = true;
if ( !a ){
System.out.print(a);
a = !b;
}
if (!b && a){
c = !a;
System.out.print(!c);
}
if (a || !c) {
b = !b;
System.out.print(b);
}
20. When the code above runs, it will print [ truetruetrue / truefalsetrue / truetruefalse /
falsefalsefalse / falsetruefalse / falsetruetrue
21. When the code above finishes running, the value of a is [ true / false ]
22. When the code above finishes running, the value of b is [ true / false ]
23. When the code above finishes running, the value of c is [ true / false ]
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
!A && !B
A
True
True
False
False
B
True
False
True
False
!A || !B
A
True
True
False
False
B
True
False
True
False
A || ! B
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
36
Name: _________________________ Date: ____________________ Period: _____
Boolean Logic Re-Test KEY
Objective: Demonstrate understanding of Boolean operators and their effect on condition
evaluations.
Instructions: Examine the code below as you choose all correct answer for each question.
The following are Boolean variables used to describe a crowd: G = Girls, I = ID badge, U = Untucked shirt
1.
Boys with un-tucked shirts. ( B && U ) / ( !G && U ) / ( !G || U )
2. Girls with tucked-in shirts and ID badges. ( G && !U && I ) / ( G || !U || I ) / ( !G && !U &&
!I )
3. Boys with no ID badge. ( !G || !I ) / ( !G && I ) / ( !G && !I )
Match the descriptions to the Venn diagrams by writing the number of the description in
the blank above the diagram.
4. Girls who have ID, and their shirts are tucked-in
5. People with ID and un-tucked shirts
6. Boys who have un-tucked shirts and IDs
7. Girls who have neither IDs, nor un-tucked shirts
8. Girls who have IDs
9. Boys who have either IDs or un-tucked shirts
10. Girls who have either ID or un-tucked shirts
11. Girls who don’t have ID, but they do have un-tucked shirts
12. Girls who have ID and un-tucked shirts
_ _12 _
_ 17_ _
_ _5 _
_ _15 _
_ _4 _
_ 16_ _
_ _8 _
_ _19 _
_ _10_ _
__6_
_ _7_ _
_ 13_ _
_ 14_ _
_ 18_ _
Match the logic expressions below with the Venn diagrams above by writing the number
of the expression in the blank below the diagram.
13. G && ( I || U )
14. !G && ( I && U )
15. ( I && U )
16. G && ( I && ! U )
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
37
17. G && ( I && U )
18. G && ( ! I && ! U )
19. G && I
boolean a = false, b = false, c = true;
if ( !a ){
System.out.print(a);
a = !b;
}
if (!b && a){
c = !a;
System.out.print(!c);
}
if (a || !c) {
b = !b;
System.out.print(b);
}
20. When the code above runs, it will print [ truetruetrue / truefalsetrue / truetruefalse /
falsefalsefalse / falsetruefalse / falsetruetrue
21. When the code above finishes running, the value of a is [ true / false ]
22. When the code above finishes running, the value of b is [ true / false ]
23. When the code above finishes running, the value of c is [ true / false ]
Complete the truth tables below.
A
True
True
False
False
B
True
False
True
False
!A && !B
False
False
False
True
A
True
True
False
False
B
True
False
True
False
!A || !B
False
True
True
True
A
True
True
False
False
B
True
False
True
False
A || ! B
True
True
False
True
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
38
Name: _________________________ Date: ____________________ Period: _____
Gates and Boolean Expressions
Objective- Construct simple schematics from Boolean expressions, and translate
schematics into Boolean expressions. Apply understanding of gates to create a
schematic that satisfies output requirements.
Instructions- Refer to the powepoint ‘Digital Gates’, if needed, to complete the exercise
below.
#1 Gates to Boolean Expressions
1. Write the Boolean expression for the following schematic.
Answer:
2. Write the Boolean expression for the following schematic.
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
39
Answer:
#2 Boolean Expressions to Gates
3. Draw the schematic for the Boolean expression !(A || B) && (!A && !B)
#3 Problem Solving- Design a circuit that receives binary numbers as input, and
turns on certain lights, depending on the input. There are only two inputs ( A, B) on
which four different binary numbers may be represented. Remember that binary 00 = 0,
binary 01 = 1, binary 10 = 2, binary 11 = 3. The circuit has three outputs ( #1, #2, #3).
Each output is attached to a light. If there are 5 volts on the output, the light is turned
on. If no lights are on, this represents zero. If the light on output #1 is on, it represents
“one”, if light #2 is on, it represents a “two”, if light #3 is on it represents a “three”. Make
sure that the circuit behaves according to the table below. The 0’s and 5’s in the input
and output rows represent 0 and 5 volts. Use scratch paper to work through the problem
and copy a working circuit to the space below. Hint- consider the inputs for each output
separately.
Counting
0
1
2
3
Number
Input A
0
5
0
5
Input B
0
0
5
5
Output #1
0
5
0
0
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
40
Output #2
Output #3
0
0
0
0
5
0
0
5
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
41
Name: _________________________ Date: ____________________ Period: _____
Gates and Boolean Expressions KEY
Objective: Construct simple schematics from Boolean expressions, and translate schematics
into Boolean expressions. Apply understanding of gates to create a schematic that satisfies
output requirements.
Instructions: Refer to the Presentation ‘Digital Gates,’ if needed, to complete the exercise
below.
#1 Gates to Boolean Expressions
1. Write the Boolean expression for the following schematic.
KEY:
!((( !A &&B) || !C) || (!A &&B))
2. Write the Boolean expression for the following schematic.
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
42
KEY: !(!A && B) && (A || !B)
#2 Boolean Expressions to Gates
3. Draw the schematic for the Boolean expression !(A || B) && (!A && !B)
#3 Problem Solving: Design a circuit that receives binary numbers as input, and turns on
certain lights, depending on the input. There are only two inputs: ( A, B) on which four different
binary numbers may be represented. Remember that binary 00 = 0, binary 01 = 1, binary 10 =
2, and binary 11 = 3. The circuit has three outputs (#1, #2, #3). Each output is attached to a
light. If there are 5 volts on the output, the light is turned on. If no lights are on, this represents
zero. If the light on output #1 is on, it represents “one;” if light #2 is on, it represents a “two;” if
light #3 is on it represents a “three.” Make sure that the circuit behaves according to the table
below. The 0’s and 5’s in the input and output rows represent 0 and 5 volts. Use scratch paper
to work through the problem and copy a working circuit to the space below. Hint: consider the
inputs for each output separately.
Counting
Number
Input A
Input B
Output #1
Output #2
Output #3
0
1
2
3
0
0
0
0
0
5
0
5
0
0
0
5
0
5
0
5
5
0
0
5
KEY- The simplest circuit is three AND gates. The first AND gate has inputs A && !B, the
second AND gate has inputs !A && B, the third AND gate has inputs A&&B.
IT: [Computer Programming]: [Boolean Logic] Plan
Copyright © Texas Education Agency, 2013
43
© Copyright 2026 Paperzz