R

Ram Sharma • 3.40K Points
Extraordinary

Q. What will be the output of this code?

Code:
def add(x, y=5):
return x + y

print(add(3))
  • (A) 3
  • (B) 5
  • (C) 8
  • (D) Error
  • Correct Answer - Option(C)
  • Views: 3
  • Filed under category Python
  • Hashtags:

Explanation by: Ram Sharma
The function `add` has a default parameter y=5. So, add(3) means x=3 and y=5, and returns 8.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.