When you omit parameters from a function call, values can be provided by A. formal parameters B. reference parameters C. overloaded parameters D. default parameters

[amp_mcq option1=”formal parameters” option2=”reference parameters” option3=”overloaded parameters” option4=”default parameters” correct=”option4″]

The correct answer is D. default parameters.

A default parameter is a parameter that has a default value assigned to it. This means that if you omit the parameter from a function call, the default value will be used instead.

For example, consider the following function:

def add(x, y=0):
return x + y

In this function, the parameter y has a default value of 0. This means that if you call the function as add(1), the value of y will be 0 and the function will return 1.

Default parameters can be useful when you want to provide a default value for a parameter that is not always necessary. For example, if you have a function that takes a string as a parameter, you might want to provide a default value of an empty string so that the function can be called without specifying a string.

Here are some additional details about the other options:

  • Formal parameters are the parameters that are declared in the function definition. For example, in the function add(), the parameters x and y are formal parameters.
  • Reference parameters are parameters that are passed by reference. This means that the function can modify the value of the variable that is passed as the parameter.
  • Overloaded parameters are parameters that have the same name but different types. This can be useful when you want to have a function that can be called with different types of arguments.

I hope this helps!

Exit mobile version