The if Statement

The if statement is used to execute one piece of code if a test statement is true, or (optionally) another if the statement is false:

if test_statement: true_code
[ else false_code ]

Examples of the if statement are shown below.

# here we execute a single statement

if x > 5: x = 20.
else x = 0.

# here we execute multiple...

if x > 5: {
        x = 20.
        y = 40.
} 

# here we execute multiple statements in the if, but only one in the else...

if x > 5: {
        x = 20.
        y = 40.
} else x = 200.