Python bool() method is a built-in method. It returns a boolean value either True or False. In numeric context, True and False represented by 1 and 0 respectivly. It returns False if the argument is not provided or the argument is False. Otherwise it returns True.
Parameter | Description |
---|---|
x | (Optional) It is a single argument which can be a numeric, string or other types as well. |
It returns a boolean value either True or False.
Let’s first understand, how this method works and what does it return?
As we know, this method takes an argument. So, we applied boolean, numeric and string arguments to check its return value.
We can also use conditional expression which returns boolean value. See the example below.