Day 79-82 #90DaysOfDevops

Today, I explored the concepts of Booleans and Operators in Python
Starting off with Boolean, it is one of the simplest yet most powerful tools in programming logic. It’s fascinating how just two values, True
and False
, can control the flow of an entire program.
I started with basic comparisons. Python allows you to compare values like 10 > 9
or 10 == 9
, and immediately returns a Boolean result: either True
or False
. It’s pretty straightforward but incredibly useful when writing conditions. I experimented with an if-else
block where I compared two variables. If the condition was true, Python executed one block of code; if false, it executed another. It felt like giving my code a sense of decision-making.
Next, I discovered the bool()
function. This built-in function can evaluate any value and tell you if Python considers it True
or False
. For instance, non-empty strings like "Hello"
or numbers like 15
return True
. But values like ""
(an empty string), 0
, None
, or empty collections like []
, {}
, and ()
all evaluate to False
.
This led me to an interesting insight: most values in Python are considered True
, as long as they’re not empty or explicitly false. Even custom objects can be evaluated this way. If you define a class with a __len__
method that returns 0, Python will treat instances of that class as False
.
Lastly, I looked at some built-in Python functions that return Boolean values. For example, isinstance(x, int)
checks whether a variable is of a specific type — in this case, if x
is an integer. These kinds of tools are great for writing safer, more predictable code.
I also explored Python operators, the symbols and keywords that let us perform actions on values and variables. At first glance, they seem simple, like using +
to add two numbers, but there's a whole system behind them.
Python groups its operators into several types. First, arithmetic operators cover the basics like +
, -
, *
, and /
, but also include things like **
for exponentiation and //
for floor division. I practiced with a few expressions, and it was great to see how intuitive they are.
Next were assignment operators. not just =
for setting values, but also shorthand like x += 3
or x *= 2
, which save time and make code cleaner.
I then looked at comparison operators (==
, !=
, >
, <
, etc.) and saw how they return True
or False
based on how two values relate. Combined with logical operators like and
, or
, and not
, they allow for more complex conditions in if
statements.
Things got more interesting with identity and membership operators. is
checks if two variables point to the same object, while in
checks if a value exists within a list or string. They’re subtle but powerful tools in the right context.
Lastly, I touched on bitwise operators, which perform operations at the binary level. They're not something I’ll use daily yet, but it’s good to know they exist.
I also learned about operator precedence, the rules that determine which operations are performed first. For instance, multiplication happens before addition unless parentheses change the order. (BODMAS)
Overall, learning about operators gave me a clearer sense of how Python evaluates expressions and how to write more precise logic. It’s like discovering the grammar behind the language.
Overall, this was a solid foundation lesson. Booleans and operators may seem basic, but they’re at the core of every decision a program makes. From filtering data to validating user input and controlling loops, it all starts with knowing what’s True
and what’s False
.
Cheers to many more days.
Subscribe to my newsletter
Read articles from Odunayo Idowu directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Odunayo Idowu
Odunayo Idowu
Aspiring Devops engineer eager to make an impact.