6.6 - Variable-Length Arguments: *args and **kwargs
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
What does *args allow in a Python function?
💡 Hint: Think about how many numbers you can add to a function.
What type of data structure does **kwargs use?
💡 Hint: Consider how you can access values by keys.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What does the * in *args signify?
💡 Hint: Think about what happens to extra inputs in a function.
True or False: **kwargs must always include at least one argument.
💡 Hint: Remind yourself of the flexibility provided by kwargs.
2 more questions available
Challenge Problems
Push your limits with advanced challenges
Design a function that accepts an unknown number of scores, calculates the average, and allows for an optional keyword argument to specify whether to round the result.
💡 Hint: Think about how you can control the output format with a keyword argument.
Write a function with both args and *kwargs that returns a formatted string detailing provided items and attributes.
💡 Hint: Make use of both collected positional and keyword arguments to build your output.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.