AP CSP Topic 3.5 Coding Practice - Boolean Expressions

Big Idea 3: Algorithms and Programming · Topic 3.5 · Coding Practice

Boolean Expressions — Code It Yourself

Write real code and check it against the expected output. Pick Python or JavaScript; the AP pseudocode reference is there when you need it.

You warmed these up on paper in Trace the Gate and Write the Rule — evaluating comparisons and combining them with NOT, AND, and OR at The Gauntlet's entry gate. Now type and run them for real, hardest last: the first prints a single height comparison, and the last builds the full boarding rule from scratch. Predict each True/False result first, then check it. Python prints Booleans as True and False.

Problem 1 of 4

The Gauntlet requires riders to be at least 48 inches tall. With height = 50, print the Boolean value of height ≥ 48 (should be True).

Expected output: True

Show AP pseudocode reference
height ← 50
DISPLAY(height ≥ 48)
'At least 48' means 48 counts, so use >= , not > . The comparison height >= 48 evaluates to a Boolean; print it directly.

Problem 2 of 4

A rider may board only if they are tall enough AND they hold a ticket. With height = 50 and hasTicket = False, print the Boolean value of (height ≥ 48) AND hasTicket (should be False).

Expected output: False

Show AP pseudocode reference
height ← 50
hasTicket ← false
DISPLAY((height ≥ 48) AND hasTicket)
height >= 48 is True, but has_ticket is False. AND needs BOTH true, so True AND False is False. Use 'and' in Python.

Problem 3 of 4

The express lane opens to a VIP OR a fast-pass holder, as long as the ride is NOT closed. With isVIP = False, hasFastPass = True, rideClosed = False, print the value of (isVIP OR hasFastPass) AND (NOT rideClosed) (should be True).

Expected output: True

Show AP pseudocode reference
isVIP ← false
hasFastPass ← true
rideClosed ← false
DISPLAY((isVIP OR hasFastPass) AND (NOT rideClosed))
Inside-out: (False OR True) is True because OR needs just one; (NOT False) is True; True AND True is True. Use or, and, not in Python.

Problem 4 of 4

Write the full boarding rule from scratch. A guest boards when they are at least 48 inches tall, they hold a ticket, and the ride is open. Using the given values (height = 46, hasTicket = True, rideOpen = True), print the Boolean value of the complete rule (should be False).

Expected output: False

Show AP pseudocode reference
height ← 46
hasTicket ← true
rideOpen ← true
DISPLAY(height ≥ 48 AND hasTicket AND rideOpen)
Chain the three conditions with AND: height >= 48, has_ticket, ride_open. Height is 46, which is below 48, so the first operand is False — and one False makes the whole AND False.

Your code runs on a secure external service. Answers are checked automatically — nothing is stored.

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]