Javatpoint Logo
Javatpoint Logo

Python bool() Method

Python bool() method returns boolean either True or False. If argument is False it returns False, otherwise it returns True. Python uses the standard truth testing procedure to return boolean value. The signature of the method is given below.

Signature

Parameters

[x]: An optional parameter.

Return

It returns a string containing printable representation of an object.

Let's see some examples of bool() method to understand it?s functionality.

Python bool() Method Example 1

This example takes a string argument and returns True.

Output:

True

Python bool() Method Example 2

If a string is provides, it returns false. But returns true for empty string value. See the example below.

Output:

True
False

Python bool() Method Example 3

It returns True if the argument is true and false if the argument is false. See the example below.

Output:

True
True

Python bool() Method Example 4

Output:

True
False
False

Next TopicPython Functions




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA