Boolean Expressions and Logic Homework
Quick practice with Boolean Expressions and Logic
📘 AP CSP Unit 3.5 Boolean Expressions Homework (JavaScript)
Part A: Write Boolean Expressions
Write Boolean expressions for the following situations. Use && (and), || (or), and ! (not).
- You can watch a movie if you finished your homework and your age is at least 13.
- You can get dessert if you ordered dinner or your parent says yes.
- You can go outside if it is not raining and the temperature is greater than 60.
- A student is eligible for a discount if they are a student and their age is less than 18.
Type the appropriate answers to the questions here:
1.
2.
3.
4.
Part B: Predict the Output
What will each of these expressions evaluate to in JavaScript? (true or false)
1. (5 > 3) && (10 < 20)
2. (7 === 7) || (4 > 10)
3. !(false) && (3 <= 3)
4. (true || false) && !(5 === "5")
5. (12 % 2 === 0) && (15 % 2 === 1)
Type the appropriate answers to the questions here:
1.
2.
3.
4.
Part C: Debugging
Some students wrote Boolean expressions but made mistakes. Fix the errors.
- if (x > 10 and y < 5)
- if (not isOnline)
-
if (age => 16 hasLicense)
Type the appropriate answers to the questions here:
1.
2.
3.