Recall & Review
beginner
What is a positional argument in Python functions?
A positional argument is a value passed to a function based on its position or order. The function uses the argument in the order it is given.
Click to reveal answer
beginner
Why do we use keyword arguments in Python?
Keyword arguments let us specify the name of the parameter when calling a function. This makes the code clearer and allows arguments to be passed in any order.Click to reveal answer
beginner
What is the purpose of default arguments?
Default arguments provide a default value for a parameter if no value is given when the function is called. This helps avoid errors and makes functions flexible.
Click to reveal answer
intermediate
Explain *args and why it is useful.
*args allows a function to accept any number of positional arguments as a tuple. It is useful when you don’t know how many arguments will be passed.
Click to reveal answer
intermediate
What is **kwargs and when should it be used?
**kwargs lets a function accept any number of keyword arguments as a dictionary. It is helpful when you want to handle named arguments that are not fixed.
Click to reveal answer
Which argument type allows you to call a function without specifying all parameters?
✗ Incorrect
Default arguments provide preset values, so you don't have to specify them every time.
What does *args collect inside a function?
✗ Incorrect
*args collects extra positional arguments as a tuple.
Why use keyword arguments when calling a function?
✗ Incorrect
Keyword arguments let you specify parameters by name, so order does not matter.
What type of argument is **kwargs?
✗ Incorrect
**kwargs collects extra keyword arguments as a dictionary.
Which argument type helps avoid errors when some arguments are missing?
✗ Incorrect
Default arguments provide fallback values to prevent errors.
Explain why different argument types like positional, keyword, default, *args, and **kwargs are needed in Python functions.
Think about how functions can be called in different ways and why flexibility is important.
You got /5 concepts.
Describe a real-life example where using default arguments and *args together would be helpful.
Imagine ordering something with some fixed choices and some extras.
You got /4 concepts.