In general, a Boolean variable can have only two values-True or False. Or in other words, if a variable can have only these two values, we say that it’s a Boolean variable. It’s frequently used to represent the Truth value of any given expression.
Still, you can simply assign a True or False value or indeed an expression that eventually evaluates to one of these values, If you want to define a Boolean in Python.
While writing an algorithm or any program, there are frequently situations where we want to execute different law in different situations. Booleans help our law to do just that easy and effective. More frequently, a Boolean value is returned as a result of some kind of comparison operations.
AND
The AND Boolean driver is analogous to the bitwise AND driver where the driver analyses the expressions written on both sides and returns the affair.
OR
The OR driver is analogous to the OR bitwise driver. In the bitwise OR, we were riveting on either of the bit being 1. Then, we take into account if either of the expression is true or not. However, accordingly, the result is true, If at least one expression is true.
NOT
The NOT driver reverses the result of the Boolean expression that follows the driver. It's important to note that the NOT driver will only reverse the final result of the expression that incontinently follows. Also, the NOT driver is denoted by the keyword "not".
These drivers are important not only in Python but in any programming language as it helps us to make sense into the program. Knowing the priority and prosecution inflow of these drivers is extremely necessary because similar crimes aren't stressed by the compiler. So, if you find commodity wrong with the results, there are great chances that at some point any driver got lost. Keep rehearsing with different use cases to gain mastery over the drivers.
Comments