QuestionQ113

VerifiedMiscellaneous (List Comprehensions, Lambdas, Closures, I/O)

What behavior is expected from the following code?

Question Image

Explanation

The conditional expression returns -x only when x is greater than zero; otherwise, it returns x. With x equal to -2, the condition is false, so the output is -2.

Community Discussion

No comments yet. Be the first to start the discussion!