Boolean in Python

If I ask you, is Elon Musk rich? Your answer will either be True or False.

Similarly, if someone asks you,

is it hot today?

Is she beautiful?

Is this shoe red?

Is your aunt drunk?

Your answers to each question are either True or False. That means the value we give your answers is a Boolean variable.

A Boolean variable is one whose value is either True or False.

Writing a Boolean type variable is quite easy. You have to write the variable name followed by an equal sign and then assign the value True or False to it. Always ensure that True or False (whichever you choose) starts with a capital letter T or F.

For example, the following are Boolean variables:

game_over = True
isRich = False

When the value of a variable is True or False, you don’t need any quotation marks. This is because Python recognizes these two keywords and has assigned them for the Boolean variable type.

Now, you have learned about the print () function and Variables. Open your social media (whichever you like) and post something about the print () function and variable types. Make a post and shine. You are learning, and you have to live the life of a programmer now.  

The more you write about what you learn in your own words, the more it sticks.

Do you want to become an expert programmer? See books helping our students, interns, and beginners in software companies today (Click here)!

Leave a Comment

Python Tutorials