if / else
Run different code branches based on whether a condition is True or False.
- Indentation defines branch bodies.
- elif chains; trailing else optional.
- Conditional expression: a if cond else b.
When to use: Threshold decisions, conditional preprocessing, device fallbacks.
Example: class_label = "spam" if prob >= 0.5 else "ham".