Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara What is a Boolean Data Type? | Boolean Type
Python Data Types

book
What is a Boolean Data Type?

It's time to move to the Boolean data type. Variables that are Boolean data types can take the following values: either False or True.

Keywords False and True are capitalized, if we write lowercase we will get an error.

python
Input:
a = True
print(type(a))

b = False
print(type(b))

Output:
<class 'bool'>
<class 'bool'>
python
Input:
x = 15 > -5
print(x)
print(type(x))

Output:
True
<class 'bool'>
python
Input:
y = 17 < 4
print(y)
print(type(y))

Output:
False
<class 'bool'>

In Python, data types such as Boolean and integer are very interrelated, namely the default Boolean value False is represented by an integer 0, and Boolean value True is represented by an integer 1.

Compito

Swipe to start coding

You have to fill in the blanks so that all expressions will be True.

Soluzione

a = (10 < 56)
print(f'The statement a is {a}')
b = (3 > -43)
print(f'The statement b is {b}')
c = (78 == 78)
print(f'The statement c is {c}')

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 1
a = (10 _ _ _ 56)
print(f'The statement a is {a}')
b = (3 _ _ _ -43)
print(f'The statement b is {b}')
c = (78 _ _ _ 78)
print(f'The statement c is {c}')

Chieda ad AI

expand
ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

some-alt