Boolean value is something either True or False.
isGood = True isBad = False print(isGood) print(type(isGood)) print(isBad) print(type(isBad))
True <class 'bool'> False <class 'bool'>
Boolean is mainly used for justifying a condition. Let me clear:
Two friends have brought some marbles from a shop but one does not know the other’s number. They decide if friend1 has more marbles than friend2 then friend1 will give a treat to friend2 otherwise friend2 will the treat. Let’s see actual number of marbles they have and determine who has the higher number of marbles:
friend1_marbles = 20 friend2_marbles = 18 # checking if friend1_marbles is greater than friend2_marbles condition = friend1_marbles>friend2_marbles print(condition) print(type(condition))
True <class 'bool'>
We will similar kind of examples when we will study conditional statements(if..else)