True Keyword

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:

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:

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

 


Copyright 2023 © pythontic.com