Question: 3. (20pt) Consider the two Python programs below: # program P1 # program P2 def A(I, P): def B(): print(I) if I > 2: P()

 3. (20pt) Consider the two Python programs below: # program P1

3. (20pt) Consider the two Python programs below: # program P1 # program P2 def A(I, P): def B(): print(I) if I > 2: P() elif I > 1: A(3, P) else: A(2, B) def CO: print(2) def A(I, P): def BO): print(I) if I > 2: PC) elif I > 1 : A(3, B) else: A(2, B) def CO: print(2) I = input() A(I, C) I = input() A(I, C) (1) (1pt) Find the differences between the source code of the two programs. (2) (2pt) Find the output of each program for all possible real values of I. (3) (2pt) Find the real values of I for which the two programs have the same output. 1 (4) (15pt) Explain the output of each program in all details. For all possible cases, provide drawings of the stack showing the frames for all subroutines and the static links indicating which procedure each P refers to and which variable the I in print(I) refers to. Provide as much information as necessary to clarify what happens during the running of the programs

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!