Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Boolean Data Type | Conditional Statements
Introduction to Python

Boolean Data Type

Welcome to section three! In this section, we'll dive into another Python data type: the boolean or logical type. Booleans can only have one of two values: True or False. This data type comes into play when evaluating logical conditions.

Here are the logical operators for comparison:

Operator Description
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to

When you apply these operators, the result will be a boolean value: True if the condition is met, and False if it isn't. For instance, consider the following evaluations:

Code Description
Second line: The first True indicates that 1 is equal to 1 (which is self-evident);
Fourth line: The second False suggests that the strings "abc" and "aBc" differ due to the case sensitivity.
Sixth line: The final False implies that 87*731 isn't greater than or equal to 98*712. In fact, 63597 is less than 69776

Task

  • Is first_integer variable less than or equal to second_integer? (It must return True if the first variable is less than or equal to the second, and False if it is greater than the second)
  • Is the string "text"not the same as "TEXT"
  • Does the string length of "Python" equal 6?
question-icon

Fill in the blanks to complete the task.

# Check the following statements
print(first_integersecond_integer)
print("text""TEXT")
print(len("Python")6)
True
True
True

Click or drag`n`drop items and fill in the blanks

¿Todo estuvo claro?

Sección 3. Capítulo 1
course content

Contenido del Curso

Introduction to Python

Boolean Data Type

Welcome to section three! In this section, we'll dive into another Python data type: the boolean or logical type. Booleans can only have one of two values: True or False. This data type comes into play when evaluating logical conditions.

Here are the logical operators for comparison:

Operator Description
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to

When you apply these operators, the result will be a boolean value: True if the condition is met, and False if it isn't. For instance, consider the following evaluations:

Code Description
Second line: The first True indicates that 1 is equal to 1 (which is self-evident);
Fourth line: The second False suggests that the strings "abc" and "aBc" differ due to the case sensitivity.
Sixth line: The final False implies that 87*731 isn't greater than or equal to 98*712. In fact, 63597 is less than 69776

Task

  • Is first_integer variable less than or equal to second_integer? (It must return True if the first variable is less than or equal to the second, and False if it is greater than the second)
  • Is the string "text"not the same as "TEXT"
  • Does the string length of "Python" equal 6?
question-icon

Fill in the blanks to complete the task.

# Check the following statements
print(first_integersecond_integer)
print("text""TEXT")
print(len("Python")6)
True
True
True

Click or drag`n`drop items and fill in the blanks

¿Todo estuvo claro?

Sección 3. Capítulo 1
some-alt