Python
GATE Data Science & AI · Programming - Python · 2026-2026
Study anchor
Source-book anchor pending for this concept.
Practice action
Start latest PYQPYQs in this concept
All concepts →Consider the given Python program. def append_to_lst(val, lst=[]): lst.append(val) return lst print(append_to_lst(1)) print(append_to_lst(2)) print(append_to_lst(3, [])) Which of t...
A recursive function in Python is given. def mystery(n): if n <= 0: return 1 else: return mystery(n-1) + mystery(n-2) Now, consider the following function call: mystery(4) Assume t...
Consider the given Python program. def outer(): x = [] def inner(val): x.append(val) return x return inner f1 = outer() f2 = outer() print(f1(10)) # Line P print(f1(20)) # Line Q p...
Consider the given Python program. def fun(L, i=0): if i >= len(L)-1: return 0 if L[i] > L[i+1]: L[i+1], L[i] = L[i], L[i+1] return 1+fun(L, i+1) else: return fun(L, i+1) data = [5...