Logical NOT in Python
The logical NOT is used to denote negation in a condition. It is written using the construction not.
Let us have a variable:
tst = 2
Let's set a condition - is the variable greater than 0 and at the same time not less than 1:
if tst > 0 and not tst < 1:
print('+++') # this will work
else:
print('---')
The following code is given:
tst = 15
if tst > 20 and not tst < 10:
print('+++')
else:
print('---')
Tell me what will be output to the console.
The following code is given:
tst1 = -8
tst2 = 10
if tst1 > -10 and not tst2 < 10:
print('+++')
else:
print('---')
Tell me what will be output to the console.