bool(object)
object :input any object 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
x=4
y=bool(x)
print(type(y)) # <class 'bool'>
Author
🎥 Join me live on YouTubePassionate 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.