Conditional (if / else)

Applies to: general

A conditional runs different code depending on whether a condition (a boolean) is true. if / else if / else chains let a program make decisions, the most basic form of logic.

if speed > limit:
    state = "too fast"
else:
    state = "ok"

See also: boolean