bool()

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() will return False for following inputs
empty string, empty list , any empty iterable object , None , 0 ,False

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

Your Rating




Post your comments , suggestion , error , requirements etc here




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