#FUNCTION
# A function is a block of code which only runs when it is called.
# You can pass data, known as parameters, into a function.
# A function can return data as a result.
#function is define using def keyword.
def hello(greeting):
return greeting
#calling the function
hello("hello")
#defining a function with default value.
def hello_func(greeting, name='kushagra'):
return '{}, {}'.format(greeting,name)
hello_func('hi')
print(hello_func('hi','Jack'))
#Use *args - for variable number of arguments
#Use *kwargs - for variable number of keyword arguments
def student_info(*args, **kwargs):
print(args)
print(kwargs)
#student_info function accepting *args & **kwargs and printing it.
student_info('Math', 'Art', name='Jean', age=23)
#list
courses=['Math','Art']
#dictionary
info={'name': 'jane', 'age': 25}
#passing courses list and info dictionary to our function student_info
student_info(courses,info)
#all these are passed as an argument.
#so we need to specify arguments and keyword arguments
student_info(*courses,**info)