From a strictly beginner standpoint of view, return True and return False may help the learner to grasp the logic and where the two boolean states fit in.
But then the bar is raised and we are given to tackle truthy and falsy which are not boolean literals, but expressions that evaluate to True or False. Once we are comfortable with this concept, we can set aside the boolean literals and work strictly with the expressions.
As a rule I never compare booleans directly.
if A === True
is just as easily handled by the Python (or any other language that supports truthy or falsy operations),
In the case of your first example, if this were inside a function,
return not not x
that will return a boolean if
x is a value. If
x is a relation (any comparison) then,
It will still return a boolean since
x is evaluated before the return. The literals need never appear anywhere in our source code.
Your second example makes nested comparisons with only a True outcome if all three variables are truthy. We can do this with logical operators:
return x and y and z
will return a boolean if at least
z is an expression, and not value only, else it will return
z as the value.
return x and y and not not z
will return a boolean regardless whether values or expressions.
not x is a boolean toggle, as in the negation of the evaluation of x (and casting to boolean), then,
not not x
will always return the boolean that describes the truthy or falsy state of
not 1 => False
not not 1 => True