Loading...

if / else

Run different code branches based on whether a condition is True or False.

When to use: Threshold decisions, conditional preprocessing, device fallbacks.

Example: class_label = "spam" if prob >= 0.5 else "ham".

More Python for ML Glossary terms