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 → True
b) 12 < 15 → True
c) 5 == 2 → False
—
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 = 10
print(num % 2 == 0)
True
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) False b) True c) 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)
finished_homework = True
test_score = 85
can_go_out = finished_homework and test_score >= 80
print(can_go_out)
True
b)
is_cloudy = False
temperature = 80
leave_umbrella = not is_cloudy and temperature > 75
print(leave_umbrella)
True
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. Type whether I, II, III, mulitple, or none of the above is correct
II & III
B. Explain why you made your choice in question A
Expressions II and III both capture that range (16 ≤ age < 18).