Python *args and **kwargs Quiz
- Questions: 15
- Easy
- Pass mark: 70%
Some functions need to take any number of values: a log that records every reading, a launch that accepts optional settings, a helper that passes everything on to another function. In Python, *args collects extra positional arguments into a tuple and **kwargs collects extra keyword arguments into a dictionary. This free quiz has 15 short questions on both, and on * and ** in function calls.
What the quiz covers
- What
*argsand**kwargshold inside the function: a tuple and a dictionary - Mixing regular parameters,
*args, default values and**kwargsin one function - Reading keyword arguments with
get()and looping over them withitems() - Unpacking a tuple, a string or a dictionary into a call with
*and** - Passing
*argsand**kwargson to another function
How it works
- 15 questions: 11 with one correct answer, 4 where you select every correct answer
- After each question you see the correct answer and a short explanation
- No time limit and no account needed
- Score 70% or more (11 of 15) to pass
You can try each idea in a runnable example: variable arguments with *args, variable keyword arguments with **kwargs, combining argument types and positional and keyword arguments. After this one, try the Python Functions Quiz or the Python Return Values Quiz.
This quiz is for registered users. Log in to take it.
Log inLog in to save this result to your progress. Log in
Next up: Local and Global Variables →