Recall & Review
beginner
What is the correct order of arguments in a Python function definition?
The correct order is: positional arguments, default arguments, *args (variable positional arguments), keyword-only arguments, and **kwargs (variable keyword arguments).
Click to reveal answer
beginner
Why must positional arguments come before default arguments in Python functions?
Because Python assigns values to arguments in order. If a default argument came before a positional one, Python wouldn't know which value belongs where.
Click to reveal answer
beginner
What happens if you put a default argument before a positional argument in a function definition?
Python will raise a SyntaxError because default arguments must follow positional arguments.
Click to reveal answer
intermediate
What is the role of *args and **kwargs in argument order?
*args collects extra positional arguments as a tuple, and **kwargs collects extra keyword arguments as a dictionary. They must come after positional and default arguments.
Click to reveal answer
intermediate
How do keyword-only arguments fit into the argument order?
Keyword-only arguments come after *args and must be specified by name when calling the function. They can have default values.
Click to reveal answer
Which of the following is the correct order of arguments in a Python function?
✗ Incorrect
The correct order is positional, default, *args, keyword-only, then **kwargs.
What error occurs if a default argument is placed before a positional argument?
✗ Incorrect
Python raises a SyntaxError if default arguments come before positional arguments.
What does *args collect in a function?
✗ Incorrect
*args collects extra positional arguments as a tuple.
Where do keyword-only arguments appear in the argument order?
✗ Incorrect
Keyword-only arguments come after *args and before **kwargs.
Which argument type must be specified by name when calling a function?
✗ Incorrect
Keyword-only arguments must be specified by name when calling the function.
Explain the correct order of arguments in a Python function and why this order matters.
Think about how Python matches values to parameters when you call a function.
You got /6 concepts.
Describe the roles of *args and **kwargs in function arguments and their position in the argument order.
Consider how functions handle extra arguments beyond those explicitly named.
You got /5 concepts.