True keyword

True keyword in python is a constant that represents the true value of the python bool type. Any expression that does not evaluate to False will return True.

Keywords Updated 16 Mar 2017 1 min read

Overview

  • True is a python keyword.

  • True in Python is a constant of type bool.

  • The constant True represents the value corresponding to true of the boolean type bool.

  • Anything that is not evaluating to False will evaluate to True.

Example

python
intVal = 1

if intVal:

    print("Inside if block")

intval = -1

if intVal:

    print("Negative values evaluate to True")

intVal = 2

while intVal:

    print("Waiting for the keyboard interrupt:ctrl-c")

Output

Output
Inside if block

Negative values evaluate to True

Waiting for the keyboard interrupt:ctrl-c

Waiting for the keyboard interrupt:ctrl-c

Waiting for the keyboard interrupt:ctrl-c