Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!