Boolean Values
We said that all conditions are ultimately true (True) or false (False). We can verify this by printing the condition:
print(10 < 20) # Prints: True
condition = 10 != 10
print(condition) # Prints: FalseThese True and False values are called Boolean values. We can also directly use these values in code. For example:
condition = True # True
if condition:
print("This is always printed")And we can also compare them:
True == True # True
True == False # False
True != False # TrueThis may not seem very useful now, but you will see later that Boolean values are really useful.
Instructions
Create a variable discount with the value True.
If discount is true (True), print I will buy!.
Start programming for free
5/10