Question: 4) Trace this program in the following table by filling in the initial values of variables and also the values whenever they change. def
4) Trace this program in the following table by filling in the initial values of variables and also the values whenever they change. def fn(a,b): if a bi r-2 else: L 2-3 return r L-12, 5, 17, 17, 61 i-1 typel = True type2 - True while i < len(L): x-L[i-1] res fn(x,L[i]) if res-1: typel-False elif res = 2: type2= False i=i+1 print (type1, type2) ID i typel type2 X LOG b) What is the output of this program? That is, what is printed? a b T res Write the Python code for the following function fn(a,b) where a and bare two integers and a is less than or equal to b. This function returns the sum of the numbers between a and b (not including a and b). For example, calling fin(1,5) would return 9 (which is the sum of 2+3+4) For another example, calling fn(2,3) would return 0 (since there are no numbers between 2 and 3) b) Write a Python program that inputs two integers x and y. The program will print the sum of the numbers that occur between x and y. You must use the function in part 2(a). Note, the user might not enter the numbers in order (e.g. x could be greater than y). For example, if the input is 1 5, then the output should be 9 If instead the input is 5 1, the output should also be 9.
Step by Step Solution
There are 3 Steps involved in it
Solution Lets start by tracing the given program def fna b if a b elif a b r2 else 83 return r L 12 ... View full answer
Get step-by-step solutions from verified subject matter experts
