Python bool() function

Published February 17, 2022

The Python bool() function returns or converts a value to a Boolean value, i.e., True or False, following a standard truth test procedure.

The Syntax of bool()
The syntax of bool() function includes:

 bool([argument to be tested])

The bool() function generally accepts just one argument, which may be used to do basic truth checking. If no argument is specified, False is returned by default.


Example

In this example, we are going to text whether the variables x and y are equal
 

x = 50
y = 50
print(bool(x == y))

Output

True

 

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

238 Views