Computer Science

Draw flow of execution for the above program.

Python Functions

3 Likes

Answer

The flow of execution for the above program is as follows :

1 → 6 → 9 → 12 → 1 → 2 → 3 → 4 → 6 → 7 → 9 → 10 → 12

Line 1 is executed and determined that it is a function header, so entire function-body (i.e, lines 2, 3, 4) is ignored.Then line 6 is executed and determined that it is a function header, so entire function-body (i.e, line 7) is ignored, Line 9 is executed and determined that it is a function header, so entire function-body (i.e, line 10) is ignored. Then line 12 is executed and it has a function calls, so control jumps to the function header (line 1) and then first line of function-body, i.e, line 2, function returns after line 4 to function call line (line 12) and then control jumps to line 6, it is a function header and then first line of function-body, i.e., line 7, function returns after line 7 to function call line (line 12) and then control jumps to line 9, it is a function header and then first line of function-body, i.e., line 10, function returns after line 10 to function call line 12.

Answered By

2 Likes


Related Questions