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.
python9912345678910Input:a = Trueprint(type(a))b = Falseprint(type(b))Output:<class 'bool'><class 'bool'>
python912345678Input:x = 15 > -5print(x)print(type(x))Output:True<class 'bool'>
python912345678Input:y = 17 < 4print(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
9
1
2
3
4
5
6
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?
Grazie per i tuoi commenti!
Sezione 2. Capitolo 1
9
1
2
3
4
5
6
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
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione