Which is the correct syntax of a conditional expression in Python?

Options

  • A. if condition then x else y
  • B. x if condition else y
  • C. condition ? x : y
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. x if condition else y

Detailed Explanation

Explanation: Python uses value_if_true if condition else value_if_false.