Boolean logic

and, or, not, short-circuit, and De Morgan.

and, or, and not combine yes/no values. Short-circuit means Python may skip the right-hand side. De Morgan rewrites a not of a combination.

Goal

Print a tiny truth table, show short-circuit, and rewrite a negated condition.

Truth table

values = [False, True]
print("a", "b", "and", "or")
for a in values:
    for b in values:
        print(a, b, a and b, a or b)

Short-circuit

def boom():
    print("evaluated")
    return True

print("False and boom:", False and boom())
print("True or boom:", True or boom())
print("True and boom:", True and boom())

False and … never calls boom(). True or … never calls boom() either.

De Morgan

low = 3
high = 20
units = 12
print(not (units < low or units > high))
print(units >= low and units <= high)

Those two lines match. not (A or B) is (not A) and (not B).

Tip

Write the condition you mean. If you need both bounds, low <= units <= high is legal Python and reads as a range.