Python bool() Function
Description
bool() The function is used to convert a given parameter to a boolean type; if there is no parameter, it returns False.
bool is a subclass of int.
Syntax
The syntax of the bool() method is as follows:
class bool([x])
Parameters
- x -- the parameter to be converted.
Return Value
Returns True or False.
Example
The following examples show the use of the bool function:
bool
(
)
False
bool
(
0
)
False
bool
(
1
)
True
bool
(
2
)
True
issubclass
(
bool
,
int
)
bool is a subclass of int
True
Python built-in function