Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer question R5.12 We have seen three kinds of variables in Python: gl

ID: 3685693 • Letter: P

Question

Please answer question R5.12

We have seen three kinds of variables in Python: global variables, parameter variables, and local variables. Classify the variables of Exercise R5.8 according to the categories. Use the process of stepwise refinement to describe the process of making scramed eggs. Discuss what you do if you do not find eggs in the refrigerator. Perform a walkthrough of the intName function with the following arguments: a. 5 b. 12 c. 21 d. 301 e. 324 f. 0 g. -2 Consider the following function: Perform traces of the computations f(-1), f(0), f(1), f(2), f(10), and f(100).

Explanation / Answer

def f(a):
   if (a < 0):
       return -1;
   n = a
   while (n > 0):
       if (n % 2 == 0):
           n = n // 2;
       elif (n == 1):
           return 1
       else:
           n = 3*n + 1;
   return 0