मराठी
तामिळनाडू बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान इयत्ता १२

Explain the Ternary operator with examples. - Computer Science

Advertisements
Advertisements

प्रश्न

Explain the Ternary operator with examples.

टीपा लिहा

उत्तर

Conditional operator:

The ternary operator is also known as the conditional operator that evaluates something based on a condition being true or false. It simply allows testing a condition in a single line replacing the multiline if-else making the code compact.
The Syntax conditional operator is,
Variable Name = [on – true] if [Test expression] else [on – false]

Example:
min = 50 if 49 < 50 else 70 # min = 50 min = 50 if 49 > 50 else 70 # min = 70

shaalaa.com
Tokens
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 5: Python - Variables and Operators - Evaluation [पृष्ठ ६६]

APPEARS IN

सामाचीर कलवी Computer Science [English] Class 12 TN Board
पाठ 5 Python - Variables and Operators
Evaluation | Q 3. | पृष्ठ ६६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×