booleans and strings.
In this blog we will go through the topics on booleans and strings in python and how to use them. So, lets get started.
It is a datatype which takes only two values i.e, either True or False. The result of any Evaluated expression will be a boolean.
Its mostly used in conditional statements.
a = True b = False print(a , b ) print( type(a),type(b) )
True False <class 'bool'> <class 'bool'>
In python the comparasion operator is almost same as used in maths but only equals to is represented by
== and not equals to as
a = 5 b = 12 # compare a and b. print(a<b) print(type(a<b))
True <class 'bool'>
As we all now the result will be true in maths that is same as python, Any comparsion operation in python results a boolean. similarly it will result for