def calculate(n, **kwargs):
n += kwargs["add"]
n *= kwargs["multiply"]
return n
print(calculate(3, add=3, multiply=5)) # (3+3)*5 = 30
#in python, arguments can be used using keywords
#the format is:
def function(arg,kwarg='default'):
return [arg,kwarg]
complex(real=3, imag=5)
complex(**{'real': 3, 'imag': 5})
# function with 2 keyword arguments
def student(name, age):
print('Student Details:', name, age)
# default function call
student('Jessa', 14)
# both keyword arguments
student(name='Jon', age=12)
# 1 positional and 1 keyword
student('Donald', age=13)