Skip to main content

Functions In Python — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Functions In Python — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def to_upper(k): return k.upper() x = ['ab', 'cd'] print(list(map(upper, x)))

Question 2 of 40
★ FPSC ★ PPSC

Observe the following Python code? def a(n): if n == 0: return 0 else: return n*a(n - 1) def b(n, tot): if n == 0: return tot else: return b(n-2, tot-2)

Question 3 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def a(n): if n == 0: return 0 elif n == 1: return 1 else: return a(n-1)+a(n-2) for i in range(0,4): print(a(i),end=" ")

Question 4 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def printMax(a, b): if a > b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') printMax(3, 4)

Question 5 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def f(): x=4 x=1 f() x

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? l=[1, -2, -3, 4, 5] def f1(x): return x<-1 m1=map(f1, l) print(list(m1))

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? a=10 b=20 def change(): global b a=45 b=56 change() print(a) print(b)

Question 8 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = ['ab', 'cd'] print(map(len, x))

Question 9 of 40
★ FPSC ★ PPSC

How are required arguments specified in the function heading?

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def check(n): if n < 2: return n % 2 == 0 return check(n - 2) print(check(11))

Question 11 of 40
★ FPSC ★ PPSC

What is tail recursion?

Question 12 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = ['ab', 'cd'] print(list(map(len, x)))

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def f(): global a print(a) a = "hello" print(a) a = "world" f() print(a)

Question 14 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x=12 def f1(a,b=x): print(a,b) x=15 f1(4)

Question 15 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? elements = [0, 1, 2] def incr(x): return x+1 print(list(map(elements, incr)))

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def test(i,j): if(i==0): return j else: return test(i-1,i+j) print(test(4,7))

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def to_upper(k): k.upper() x = ['ab', 'cd'] print(list(map(to_upper, x)))

Question 18 of 40
★ FPSC ★ PPSC

The output of the following codes are the same. [x**2 for x in range(10)] list(map((lambda x:x**2), range(10)))

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = [12.1, 34.0] print(len(' '.join(list(map(str, x)))))

Question 20 of 40
★ FPSC ★ PPSC

What is the base case in the Merge Sort algorithm when it is solved recursively?

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x=100 def f1(): global x x=90 def f2(): global x x=80 print(x)

Question 22 of 40
★ FPSC ★ PPSC

. . . . . . . . returns a dictionary of the module namespace. . . . . . . . . returns a dictionary of the current namespace.

Question 23 of 40
★ FPSC ★ PPSC

Which keyword is used for function?

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = ['ab', 'cd'] print(len(map(list, x)))

Question 25 of 40
★ FPSC ★ PPSC

How can you define a function that accepts both positional and keyword arguments?

Question 26 of 40
★ FPSC ★ PPSC

If a function doesn't have a return statement, which of the following does the function return?

Question 27 of 40
★ FPSC ★ PPSC

What is the output of the following code: square = lambda x: x**2 result = square(5) print(result)

Question 28 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? lamb = lambda x: x ** 3 print(lamb(5))

Question 29 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = [12, 34] print(len(list(map(int, x))))

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = ['ab', 'cd'] print(list(map(upper, x)))

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = 'abcd' print(list(map([], x)))

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def f(x, y, z): return x + y + z f(2, 30, 400)

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = 50 def func(): global x print('x is', x) x = 2 print('Changed global x to', x) func() print('Value of x is', x)

Question 34 of 40
★ FPSC ★ PPSC

How many keyword arguments can be passed to a function in a single function call?

Question 35 of 40
★ FPSC ★ PPSC

Only problems that are recursively defined can be solved using recursion.

Question 36 of 40
★ FPSC ★ PPSC

What is a variable defined inside a function referred to as?

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def foo(i, x=[]): x.append(x.append(i)) return x for i in range(3): y = foo(i) print(y)

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def foo(k): k = [1] q = [0] foo(q) print(q)

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = [12, 34] print(len(''.join(list(map(int, x)))))

Question 40 of 40
★ FPSC ★ PPSC

On assigning a value to a variable inside a function, it automatically becomes a global variable.

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →