Introduction
Using if as an expression lets you choose a value based on a condition in one simple step.
When you want to set a variable to one value or another depending on a condition.
When you want to return different results from a function based on a condition.
When you want to write shorter code without repeating variable names.
When you want to decide a value inside a larger expression.