python/args_and_kargs_in_func.py

20 lines
696 B
Python

def new_func(a, b=0, *args, **kwargs):
print(f"a = {a}, b = {b}, args = {args}, kwargs = {kwargs}")
"""
A function that demonstrates the use of positional, default, variable positional (*args), and variable keyword (**kwargs) arguments.
Parameters:
a (Any): The first positional argument.
b (Any, optional): The second argument with a default value of 0.
*args: Additional positional arguments.
**kwargs: Additional keyword arguments.
Prints:
The values of 'a', 'b', 'args', and 'kwargs' in a formatted string.
Returns:
None
"""
# Example usage of the new_func function
new_func(1, 2, "Love", "Hope", name="Anna", age=20)