Menu Close

Python bool() Function

In this python built-in functions tutorial series, we are going to learn all about the Python bool function to get the boolean value of the specified object.
In the previous Python tutorial, we have seen another python built0 function that is a bin function to getting the binary value of a given integer.

What is the Python bool() function?

Python bool function is a built-in python function that is used to return the boolean value of the specific object.

Syntax

The syntax of bool function in python is:-

bool( object )

Parameter Value

bool function in python accepts only one parameter that is object.

  • object:- Any object, like String, List, Number, etc.

Return Value

Return value of bool function is always True or False.

Python bool function example

Here we will use bool function to find the boolean value.

Example 1:

Find the boolean value of 1 using bool() function.

x=bool(1)
print(x)

output will be:- True

Example 2:

Find the boolean value of 0 using bool() function.

y=0
print(bool(y))

Output will be:- False

Conclusion

The python bool() function is a built-in function the is used to getting the boolean value of the specified object. bool function in python is very useful to find the boolean value of the specified object.

if you like this article, please keep visit for the next python built-in functions tutorials.

For more information:- Click Here

Previous Article
Next Article

Was this post helpful?

Related Posts

Leave a Reply