✅ Boolean Data Type
Last Updated: 13th August 2025
- Boolean represents True or False values in Python.
- It is used for logical decisions in programs.
- Boolean values are actually a subtype of integers:
True→1False→0
Hinglish Tip 🗣: Boolean ka kaam hai "yes" ya "no" type decisions lena — True matlab haan, False matlab nahi.
Syntax
variable_name = value # True or False
Example:
is_active = True
is_logged_in = False
print(is_active) # Output: True
print(is_logged_in) # Output: False
# Type Checking
print(type(is_active)) # Output: <class 'bool'>
print(type(is_logged_in)) # Output: <class 'bool'>
Some Important Points:
There are some True and False values in Python also Known as truthy and falsy values.:
| Value | Truthy/Falsy |
|---|---|
| 0 | Falsy |
| '' | Falsy |
| [] | Falsy |
| None | Falsy |
| False | Falsy |
| Any number ≠ 0 | Truthy |
| Non-empty string | Truthy |
| Non-empty list | Truthy |
💡 Quick Practice
- Create a boolean variable with value
Trueand print its type.