Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following Python code (line numbers are not part of the code): 1 def b(h): 2 m = 3 3 print(h(2)) 4. def c():
Consider the following Python code (line numbers are not part of the code): 1 def b(h): 2 m = 3 3 print(h(2)) 4. def c(): 5 m = 1 6 def f(n): 7 print(m) 8 return mun 9 def r(): 10 m = 7 11 b(f) 12 r0 13 co (a) [4] Find the following three lines: i. the first line of function f's definition ii. the line in which f is passed as an argument of another function iii. the line in which function f is invoked Each of these three lines belong to one or more static scopes. For each one, show the line number and its inner-most scope, in the form of n[se], where n is the line number, and s and e are the start-line and end-line of its (inner-most) scope. (b) [2] For each of the four functions, b, c, f, and r, list its non-local variables (if any). (c) [4] What are the outputs of this program, using i. Python's static scoping rule, and ii. a hypothetical dynamic scoping rule, respectively
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started