Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
Lecture 67: What are *args and **kwargs used for in Python functions?
16 Views • May 21, 2025
Description
In Python, *args and **kwargs are used in function definitions to allow a function to accept a variable number of arguments.
*args (Non-Keyword Arguments): It is used to pass a variable number of non-keyworded arguments to a function. These arguments are collected into a tuple within the function.
**kwargs (Keyword Arguments): It is used to pass a variable number of keyword arguments to a function. These arguments are collected into a dictionary within the function, where the keys are the argument names and the values are the argument values.
Python
def example_function(*args, **kwargs):
print("Args:", args)
print("Kwargs:", kwargs)
example_function(1, 2, 3, name="Alice", age=30)
# Output:
# Args: (1, 2, 3)
# Kwargs: {'name': 'Alice', 'age': 30}
*args and **kwargs are useful when you don't know in advance how many arguments will be passed to a function, or when you want to create functions that are flexible and can handle different numbers of arguments.
More from User
Episode 1 – The Curious Boy from Ulm (1879-1895)
Nafees AI Lab
Top Fully Funded Scholarships in Germany 2025 🇩🇪 | Apply Now!
Nafees AI Lab
The Boy and the Dragon – “A Friend in the Sky”
Nafees AI Lab
Why Do Rainbows Appear? 🌈 | Physics in Everyday Life
Nafees AI Lab
Albert Einstein: The Genius Who Changed Time
Nafees AI Lab
Stephen Hawking’s Life in 60 Seconds: From Wheelchair to the Universe
Nafees AI Lab
Related Videos
Lecture 60: Python has some functions
Nafees AI Lab
Lecture 61: Why of functions are in Python Language
Nafees AI Lab
Excel essential 2010 lecture 23 using Functions
Sandy
How the AR Functions – Cutaway Gun Used for Demonst...
MidwayUSA
📦 Ignoring Built-In Functions and Libraries Using Python 🐍
AI_Evolutionary Technology
Guan Eng used school functions to criticise Govt, claims Chong
The Star