The flow of execution refers to the order in which statements are executed during a program run. In other words the order in which statements are executed during a program run called flow of execution.
What is Flow of Execution :
Consider the code of python
x=int(input(“Enter any no=”)) # Line 1
sqr=x * x # Line 2
print(sqr) # Line 3
In above code execution of the code is Line 1 2 3. If order is not same the code will produce error.
In above code if we include any branching (if-else or if-elif) or looping (for or while )used in prorgam , then flow of execution may depend on the conditions.
see the code given below
x=int(input(“Enter any no=”)) # Line 1
sqr=0 # Line 2
if x>0: # Line 3
sqr=x * x # Line 4
print(sqr) # Line 5
Now if x is positive number then square of number is calculated otherwise not.
Now execution is Line 1 2 3 (Now if x is above 0) 3 4
Eexecution is Line 1 2 3 (Now if x is 0 or below) 5 . Line 4 is not executed .
Now we discuss the function execution.
Flow of execution in Python Functions
Look at the video for better understanding