Python Bool


Bool function

The bool() function return a boolean value: True or False. The argument value must be of type int.

Examples

Example 1

>>> x = 5
>>> y = 2
>>> bool( x > y )
True
>>> bool( x < y )
False
>>>

Example 2

>>> bool( 1 )
True
>>> bool( -1 )
True
>>> 

Example 3

>>> a = "abc"
>>> b = "abc"
>>> bool( a = b )
Traceback (most recent call last):
  File "", line 1, in 
    bool( a = b )
TypeError: 'a' is an invalid keyword argument for this function
>>>