Thursday , September 19 2024

Which of the following lines correctly invoke the function defined below? (Select two answers) def fun(a, b, c=0): # Body of the function.

Questions BankCategory: Python Essentials 1Which of the following lines correctly invoke the function defined below? (Select two answers) def fun(a, b, c=0): # Body of the function.
Which of the following lines correctly invoke the function defined below? (Select two answers)

def fun(a, b, c=0):
    # Body of the function.
  • fun(0, 1, 2)
  • fun()
  • fun(b=1)
  • fun(b=0, a=0)

Explanation: Because the c argument is a keyword argument with a specified default value, it’s enough to call the function by specifying default values for the remaining two keyword arguments, a and b. It’s also possible to replace a keyword parameter default value with a function call with positional arguments: fun(0, 1, 2). In both cases, it’s important that all the function parameters be served.

The fun(b=1) call is incorrect because it does not specify a value for the a argument required in the function definition. The fun() call is incorrect because it does not specify the values for the a and b arguments required in the function definition.

More Questions: Python Essentials 1 (PE1) Course Final Test