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

 2. (20pt) Consider the two Python programs below: def A(I, P):def A(I, P): def B(): def B(): print (I) print(I) if I

2. (20pt) Consider the two Python programs below: def A(I, P): def A(I, P): def B(): def B(): print (I) print(I) if I > 3: if I > 3: P() P() elif I > 2: elif I > 2: A(4, B) A(4, P) elif I > 1: elif I > 1: A(3, B) A(3, P) else: else: A(2, B) A(2, B) def C(): def C(): pass A(1, 0) A(1, 0) pass (1) (1pt) Find the differences between the two programs. (2) (1pt) Find the output of each program. (3) (18pt) Explain the difference. (Python is using static scoping and dynamic binding.) Hint: Insert a print(I, P, B) statement as the very beginning of the code of A(I, P) to monitor what is going on. 2. (20pt) Consider the two Python programs below: def A(I, P): def A(I, P): def B(): def B(): print (I) print(I) if I > 3: if I > 3: P() P() elif I > 2: elif I > 2: A(4, B) A(4, P) elif I > 1: elif I > 1: A(3, B) A(3, P) else: else: A(2, B) A(2, B) def C(): def C(): pass A(1, 0) A(1, 0) pass (1) (1pt) Find the differences between the two programs. (2) (1pt) Find the output of each program. (3) (18pt) Explain the difference. (Python is using static scoping and dynamic binding.) Hint: Insert a print(I, P, B) statement as the very beginning of the code of A(I, P) to monitor what is going on

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!