# .css-fhxb3m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.css-9a49z0{margin-right:0.5rem;height:2.5rem;width:2.5rem;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;overflow:hidden;border-radius:9999px;}  Prahlad Inala

Follow

Follow # Boolean in Python

·Jul 9, 2021·

## What is Boolean in Python?

Do you ever answer your friends like yes and no? That's it you know booleans, But here we will learn how to say that it is a python way. True and False with the capital 'T' and capital 'F' Boolean values are used where we need to compare some expressions in python. We can compare the lists,tuples,sets using(==) and(!=)operators to get booleans.

### Example

``````5==5
# true

'john'=='doe'
# false

[1,2]==[2,1]
# false as order matters in list.

(1,2)==(2,1)
# false as order matters in tuples.

{1,2}=={2,1}
# true as order not matters in sets.
``````

Booleans can be converted into strings and numbers using built-in(str) and(int) functions. simple remember True=1 & False=0

Strings and Numbers can also be converted to booleans using the built-in (bool) function.

In numbers only (0) converts to false remaining all are True.

In strings only empty string('') converts to false remaining all are True.

Booleans can also be added and multiplied by numbers. when we do so the Python converts the boolean value into its number represents and then does the arithmetic.

### Example

``````5+True
#6

False-2
#-2

3*true
#3

False/5
#0
``````