7554425D-0054-440D-B95E-D2ABC13D62CD Created with sketchtool.
{body}
Your Saved Info Packages

View your saved Course or Program Packages containing pricing and detailed curriculum.

Speak with a Learning Advisor.

Have any questions? We'll call you.

Fill out the form below and a Learning Advisor will reach out at a time convenient for you.

Please pick a valid date and time between 9 AM and 8 PM eastern (Monday to Friday)

By clicking "Book a call," you accept our Terms and will also receive exclusive offers and updates about new courses, workshops and events.

Python Tutorial

Python Boolean

Ready to start your career in Data? Find out more about BrainStation's Python Course

A python boolean is the another data type that can be used to store a value in a variable.

Python Boolean

One last data type we will discover as part of this guide is called "boolean". Booleans are a data type that contains a value of True or False. It is heavily used in programming when storing information based on logical decisions. A boolean value may also be the outcome of a logical operation that results in either true or false. Before we learn about booleans, let’s learn about some special keywords in Python that help in making logical decisions within code. These keywords are not, and, & or.

  • and is a reserved keyword in Python that returns True when both the values on either side of and are true. If either of those values are False, the outcome of the expression will be false.
  • or is a reserved keyword in Python that returns True when one or both the values on either side of or is true. If both of those values are False, the outcome of the expression will be false.
  • not not simply converts a True value into False, and a False value into True.

Now, let’s see how we can leverage these concepts. Type the following code line-by-line and then we will explore how it works.

Let’s consider a scenario where a student can only graduate if they meet the following conditions:

  • They have scored above 70% in their grades
  • They have above 90% attendance
  • They have not plagiarized even once during the course.

We can design and use this scenario in code as follows:

To close off this section, we've learned about some of the most frequently used built-in data types in Python. The language offers much more, along with widely useful data types that developers use in their code.

Set Password

You already have an account with BrainStation, but you still need to set up a password.