top of page
Search

Paradigm: Parameters

Updated: May 1


Imperative Programming: Flexible Functions



# access args as a tuple and kwargs as a dictionary with specified key, value items

def function_with_args_parameter(**args):
   added_numbers = sum(args)
   return added_numbers

def function_with_kwargs_parameter(**kwargs):
    user = ', '.join(f"{key}={value}" for key, value in kwargs.items())
    return user

print(f"user is: {function_with_kwargs_parameter(first_name='Sam', last_name='Smith', age=35)}")
print(f"sum is: {function_with_args_parameter(1, 2, 3)}")






6 views

Comentários


bottom of page