Nearby lessons

13 of 40

🔸 Ternary Operator

📌 What is Ternary Operator?

Concise conditional expression.

Shorthand for simple if-else statements.

AttributeDescription
condition ? expr1 : expr2Returns expr1 if true, expr2 if false
Example02
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output