R

Ram Sharma • 3.40K Points
Extraordinary

Q. What will this code output?

Code:
def f(x, y):
return x if x > y else y

print(f(4, 7))
  • (A) 4
  • (B) 7
  • (C) True
  • (D) None
  • Correct Answer - Option(B)
  • Views: 26
  • Filed under category Python
  • Hashtags:

Explanation by: Ram Sharma

The ternary operator returns the larger of `x` or `y`. Here, 7 is greater.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.