Propositional Logic · Propositions

Lesson 4

Nikolai Chukhin · Alexander S. Kulikov

Remembering that such expressions have Boolean type is useful for simplifying code and improving its readability. For example, instead of

if x > 17:
    return True
else:
    return False
use
return x > 17
whereas instead of
if x > 17:
    return True
else:
    if z > 3:
        return False
    else:
        return True
use
return x > 17 or z <= 3