Loading...

Python Booleans

True and False are the only two values of this kind. The first letter is a capital. print(True) writes True. print(False) writes False. They are not text inside quotes, and they are not the numbers 1 and 0.

True, then False

python
print(True)
print(False)

The first line is True. The second line is False. The program adds nothing else.

A name can hold either one

ready = True stores True under the name ready. print(ready) writes True. A later line, ready = False, replaces that value. print(ready) then writes False. The first value does not stay beside the second.

Store True, then replace it

python
ready = True
print(ready)
ready = False
print(ready)

The first print is True. The second print is False.

A small first letter stops the program

true and false, with a small first letter, are not these values. Python looks for a stored name, does not find one, and the program stops. True and False must start with a capital T and a capital F.

Quotes make text

print("True") writes the letters True. That line looks the same as print(True). You cannot tell them apart from the output alone. The quotes in the code are what make it text. "False" is text in the same way. This page does not turn that text into the value True.

The next page is what else counts

This page is only True and False. It does not compare two numbers, it does not choose a branch, and it does not join two conditions. The next page says which other values a condition treats as true, including an empty text and the number 0.

Say these yourself

  1. print(True) writes True. print(False) writes False.
  2. The first letter is a capital.
  3. true with a small t stops the program.
  4. "True" in quotes is text, even when the screen looks the same.
  5. ready = False replaces an earlier True.
  6. The next page is which other values count as true.

Easy to misread

  • Writing true or false with a small first letter
  • Treating "True" as the value True because the screen matches
  • Expecting both True and False to stay stored in ready
  • Reading True as the number 1
  • Waiting for a branch or a comparison on this page

Keep

True and False are the two values. The first letter is a capital.
print(True) writes True. print(False) writes False.
A small first letter stops the program.
Quotes make text. The screen can look the same.
A later line replaces the stored value.
The next page is which other values a condition treats as true.

🧠 Test Your Knowledge

Ready to Start

Test Your Knowledge

Challenge yourself with this interactive quiz and see how well you understand the topic

❓
6
Questions
🎯
70%
To Pass
♾️
∞
Time
🔄
∞
Attempts

📝 Instructions

  • Read each question carefully
  • Select the best answer for each question
  • You can retake the quiz as many times as you want
  • Your progress will be shown at the top