Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python bool() Function

Python bool() Function

Python built-in function Python built-in 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

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 Python built-in function