Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Assign comparisons to variables

  • True and False are real boolean values.

  • False

  • True

x = 2

v = x == 2
print(v)
if v:
    print(v, "is true - who would thought? ")

v = x == 3
print(v)
if v:
    print(v, "is true - who would thought? ")
else:
    print(v, "is false - who would thought? ")

# True
# True is true - who would thought?
# False
# False is false - who would thought?