Programs · Program 7-11
Q.Program 7-11: Program to understand the low of execution using functions.
Sikkim CbseNCERTSubjective· 2mImportance★★★★★est
33% · 13/40 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Program 7-11 ("low" is a misprint for flow of execution) shows that def blocks are only remembered, not run — execution starts at the first top-level statement, dives into a function at each call, and resumes right after the call on return.
The idea. Python executes a program top to bottom, but a function's body is skipped at definition time. Control enters the body only at a call, and when the function ends, control returns to the point just after the call — even through nested calls (func2 calling func1). Print statements at each landmark make the route visible.
# Program 7-11: understanding the flow of execution using functions
def func1():
print("Inside func1")
def func2():
print("Inside func2 - calling func1")
func1()
print("Back inside func2")
print("Program execution starts")
func2()
print("Program execution ends")
Step-by-step trace
| Step | What executes | Printed |
|---|---|---|
| 1 | def func1 / def func2 are read and stored — bodies NOT run | (nothing) |
| 2 | first top-level print | Program execution starts |
| 3 | call func2() → its first line | Inside func2 - calling func1 |
| 4 | func2 calls func1() → its body | Inside func1 |
| 5 | func1 returns → next line of func2 | Back inside func2 |
| 6 | func2 returns → next top-level line | Program execution ends |
Expected output
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.