KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

In the following code snippet, what does 5 in the argument list represent?

def add(x, y=5):
    return x + y
  1. return value
  2. default value
  3. input value
  4. None of these

Python Functions

1 Like

Answer

default value

Reason — Default arguments allow a function parameter to have a predefined value. In the given function definition def add(x, y=5):, the value 5 is assigned to parameter y as its default value, which is used when no value is provided for y during the function call.

Answered By

2 Likes


Related Questions