A Boolean holds exactly one of two values: true or false. That's the whole type. And yet every decision a computer makes, every login check, every filter, every if this, then that, comes down to a Boolean.
Python capitalizes them: True and False. JavaScript writes them lowercase: true and false. Same idea, different spelling. Get the capitalization wrong and the language won't recognize the word.
Boolean values
PYTHON
is_open = True
is_closed = False
≈
JAVASCRIPT
let isOpen = true;
let isClosed = false;
Compare → Python capitalizes True/False; JavaScript uses lowercase true/false. Notice also the naming convention difference, snake_case versus camelCase, and the habit of starting Boolean names with is_ or has_, which makes the code read like a question.
EXAMPLE
loading editor…
YOUR TURN
Your turn → Create a Boolean named has_library_card and print it.
loading editor…
Syntax has to be exact. Every quote, bracket and parenthesis needs its partner, and in Python the spaces at the start of a line count. One slip and the program won't run; the message will say where.
Mark this lesson complete
Signed in, your progress follows you to every device.