bool(): converts a given value to a Boolean (either True or False)

bool(object)
object :input any object
Returns boolean vlaue ( True or False )

Examples

x=10
y=bool(x)
print(y) # True 
x='12'
y=bool(x)
print(y) # True
x='' # empty string
y=bool(x)
print(y) # False 
x=0  
y=bool(x)
print(y) # False
x=1
y=bool(x)
print(y) # True
x=[] # empty list
y=bool(x)
print(y) # False
x=() # empty tuple
y=bool(x)
print(y) # False
x={} # empty set
y=bool(x)
print(y) # False
x=None
y=bool(x)
print(y) # False 

Bool data type

We can use type() to know more about boolean data type.
x=4
y=bool(x)
print(type(y)) # <class 'bool'>


bool() will return False for following inputs
empty string
empty list
any empty iterable object
None
0
False


All Built in Functions in Python

max() Bitwise operators using bin() any()


Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer