Function
def calculate_sum(numbers):
"""
Calculate the sum of a list of numbers.
Args:
numbers (list): A list of numbers to calculate the sum of.
Returns:
float: The sum of the numbers in the list.
"""
total = 0
for num in numbers:
total += num
return total
# *args function
def print_args(*args):
"""
Print all the arguments passed to the function.
Args:
*args: A variable-length argument list.
"""
for arg in args:
print(arg)
# **kwargs function
def print_kwargs(**kwargs):
"""
Print all the keyword arguments passed to the function.
Args:
**kwargs: A variable-length keyword argument list.
"""
for key, value in kwargs.items():
print(key + " = " + str(value))
Last updated