π» Activity 3.1: Boolean Operations
π» Activity 3.1: Boolean Operations#
Booleans in Python are cast as 0
or 1
. Replace ...
with your code.
Show the sum of two
True
values.
True ...
True + True
2
Show the difference between
False
andTrue
.
False - ...
False - True
-1
What is the value of
False
times the sum ofTrue
andTrue
?
...
False * (True + True)
0
Show what happens to the datatype after two boolean values are added
print(type(False))
print(type(...))
print(type(False))
print(type(False + False))
<class 'bool'>
<class 'int'>
Write code using only booleans,
type()
, and arithmetic operators that will result in the value 13 being printed when it is evaluated.
...
print(True * 13)
13
Write code using only integers,
type()
, and logicals that will result in the value True being printed when it is evaluated.
...
print(1 == 1)
True