Boolean Expressions and Logic Homework
Quick practice with Boolean Expressions and Logic
AP CSP – 10 Minute Problem Set
Big Idea 3.5: Boolean Expressions and Logic
1. Boolean Basics (1 min)
Circle True or False:
a) A Boolean value can only be True
or False
.
b) The expression 7 == 8
evaluates to True
.
c) The expression 5 < 10
evaluates to True
.
Type the appropriate answer for each question above a) True b) False c) True
2. Relational Operators (1 min)
Fill in the blank with the correct relational operator (==, !=, >, <, >=, <=
):
a) 8 ___ 8
→ True
b) 12 ___ 15
→ True
c) 5 ___ 2
→ False
Type the appropriate answer for each question above a) 8 == 8 b) 12 < 15 c) 5 > 2
3. Modulo Operator (1 min)
Write a Boolean expression that checks if a variable num
is even.
Type the answer to the question below num % 2 == 0
4. Logical Operators (2 min)
Determine if each expression is True or False when x = 12
and y = 5
.
a) (x > 10) and (y > 10)
→ __
b) (x < 20) or (y > 10)
→ __
c) not (y < 7)
→ __
Type the appropriate answer for each question above a) (x > 10) and (y > 10) # False b) (x < 20) or (y > 10) # True c) not (y < 7) # False
5. Scenario Practice (2 min)
Write Boolean expressions for the following:
a) You can go out if you finished your homework and your test score is at least 80.
b) You can leave your umbrella at home if it is not cloudy and the temperature is greater than 75.
Type the appropriate answer for each question above a) finishedHomework and testScore >= 80 b) (not cloudy) and (temperature > 75)
6. AP-Style Question (3 min)
In a country, a person must be at least 16 years old to drive a car and at least 18 years old to vote.
The variable age
represents a person’s age.
A. Which of the following expressions correctly evaluates to True
if the person is old enough to drive but not old enough to vote?
I. (age >= 16) and (age <= 18)
II. (age >= 16) and (not (age >= 18))
III. (age < 18) and (not (age < 16))
- Circle all correct answers.
- Explain briefly why.
A. II and III B. Because both mean age is at least 16 (can drive) but less than 18 (too young to vote). II checks for age >= 16 and age < 18.
III also checks for age >= 16 and age < 18.
I is slightly off because it includes age 18, which is old enough to vote.