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.
Input:
a = True
print(type(a))
b = False
print(type(b))
Output:
<class 'bool'>
<class 'bool'>
Input:
x = 15 > -5
print(x)
print(type(x))
Output:
True
<class 'bool'>
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.
Swipe to start coding
You have to fill in the blanks so that all expressions will be True.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 3.85
What is a Boolean Data Type?
Sveip for å vise menyen
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.
Input:
a = True
print(type(a))
b = False
print(type(b))
Output:
<class 'bool'>
<class 'bool'>
Input:
x = 15 > -5
print(x)
print(type(x))
Output:
True
<class 'bool'>
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.
Swipe to start coding
You have to fill in the blanks so that all expressions will be True.
Løsning
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 3.85single