Python‎ > ‎Built-in‎ > ‎

bool()

http://www.adilwaseem.com/

Introduction
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed. The Syntax of the bool() can entertain any value either it could be numeric, strings, list, tuple to determine the validity of the statement.

Syntax
bool(x) -> bool

Parameters
Numeric, string, tuple

Examples
Look at this example, Python return the statement through the bool() statement. 
 >>> a=3
>>> b=45
>>> bool(a==b)
False

bool.__and__(self, value, /)
Return with result whether two equation are True or False.
>>> x=3
>>> y=4
>>> a=5
>>> b=6
>>> a==b.__and__(x==y)
False
>>>

bool.__or__(self, value, /)
Return with the bool tested on method.
 >>> x=3
>>> y=3
>>> a=5
>>> b=6
>>> a==b.__or__(x==y)
False

Bool(str)
value are tested after assigning the string attribute.
 >>> 
>>> bool("Python"=="python")
False
>>> bool("python"=="PYTHON".lower())
True
>>>
Comments