8.3.4 - Variable-Length Arguments
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
Define a function collect_numbers(*numbers) using *args that returns the highest number from the input.
💡 Hint: Consider using the max function on the tuple.
Create a function print_fruits(**kwargs) that prints out each fruit's name and color.
💡 Hint: Use a for loop to iterate through kwargs.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What does *args represent in a function declaration?
💡 Hint: Think about how many inputs you can pass.
True or False: **kwargs collects arguments into a list.
💡 Hint: Recall the data structure used.
1 more question available
Challenge Problems
Push your limits with advanced challenges
Write a function that accepts both args and *kwargs to accept various inputs, and print them in a formatted way.
💡 Hint: Use separate loops for args and kwargs.
Design a function that calculates average scores from an arbitrary number of test scores passed, also allowing an optional keyword argument to provide extra information.
💡 Hint: Remember to handle the division and ensure no divide by zero errors.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.