Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Introduction to Boolean Data Type | Verdadeiro ou falso?
Tipos de Dados em Python

book
Introduction to Boolean Data Type

Numeric Values in Boolean Type

In Python, any number except 0 is interpreted as True. Using only 0 and 1 helps avoid confusion when checking conditions.

Case Sensitivity

Python is case-sensitive, meaning True and False must be capitalized. Writing true or false will result in an error.

Boolean Operators

The operators >, <, !=, ==, <=, and >= are essential for making meaningful boolean statements. Without these symbols, boolean statements wouldn't serve any purpose.

Let's look at the example of simple boolean statements:

The following expressions return True:

python
1 > -5
6 != 3
8 <= 8

However, these expressions return False:

python
5 < -9
0 == 1
-890 >= 890

Tarefa

Swipe to start coding

Imagine you are an accountant and need to check several conditions for financial reports. Your task is to choose the correct operator from >, <, !=, ==, <=, >= to fill in the blanks ___ so that all expressions return False.

Solução

# All statements must be `False`
statement1 = 42 > 1000
statement2 = 45 < 8
statement3 = 3 == 6

# Print these statements
print(statement1)
print(statement2)
print(statement3)

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 1
single

single

# All statements must be `False`
statement1 = 42 ___ 1000
statement2 = 45 ___ 8
statement3 = 3 ___ 6

# Print these statements
print(statement1)
print(statement2)
print(statement3)

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

We use cookies to make your experience better!
some-alt