FUNCTIONS
Function is a code segment or sub program separately defined with some identifications for future access.
Advantages of Functions:
1. re usability
2. modularity
3. readability enhancement
Two forms of function:
1. Definition
2. Invocation or calling
Definition
specifying the code to be executed when the function is invoked. it is the job of the function
Invocation
requesting the function to start executing code in its definition
relationship between Definition and Invocation:
1. No function can be invoked unless it is defined
2. a well defined function cannot run unless it is invoked.
__main__ is the hidden block that is the starting and ending point of python program execution.
we can check it using pre-defined variable __name__
#example
print(__name__)
caller:
the function that is calling other function in its definition
called/calling:
the function which is being called by other function
#Example program
#definition of function test
def test():
print("Hi from test")
#main program
print("Starting of main")
test() #invocation of test function
print("The End")