CSE101 Midterm Exam Monsoon2019
CSE101 Midterm Exam Monsoon2019
Instructions:
1. Assume the use of Python3 in all of the questions below.
2. All questions are mandatory.
3. No doubts will be discussed during the exam.
x=_______
if(x%2==0 and x%5==3):
print(‘A’)
Q7) [2 Points] Write a function lucky_sum(a,b,c) that given 3 int values a, b and c,
return their sum. However, if one of the values is 13 then it does not count
towards the sum and the values to its right count only if they are even.
Example:
lucky_sum(1, 2, 3) → 6 lucky_sum(1, 2, 13) → 3 lucky_sum(1, 13, 3) → 1
lucky_sum(13, 1, 2) → 2 lucky_sum(13, 4, 2) → 6 lucky_sum(13, 5, 21)→0
Q8) [1 Point] Give an example code of one line that when run would result into a
name error.
Q9) [2 Points] Consider the below code. Give the maximum number of frames the
code will have at any point of time in the stack space. Show each function call
with the argument value passed to it.
def f(a):
if a == 1 or a == 0:
return 6
else:
return f(a-1) + f(a-2)
print(f(3))