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
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ 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)))
Correct Answer: Option C — error
Detailed Academic Explanation:
error is the correct answer to “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)))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 2 of 40
★ FPSC
★ PPSC
★ 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)
Correct Answer: Option C — b() is tail recursive but a() isn't
Detailed Academic Explanation:
b() is tail recursive but a() isn't is the correct answer to “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)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 3 of 40
★ FPSC
★ PPSC
★ 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=" ")
Correct Answer: Option D — 0 1 1 2
Detailed Academic Explanation:
0 1 1 2 is the correct answer to “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=" ")”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 4 of 40
★ FPSC
★ PPSC
★ 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)
Correct Answer: Option C — 4 is maximum
Detailed Academic Explanation:
4 is maximum is the correct answer to “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)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? def f(): x=4 x=1 f() x
Correct Answer: Option D — 1
Detailed Academic Explanation:
1 is the correct answer to “What will be the output of the following Python code? def f(): x=4 x=1 f() x”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 6 of 40
★ FPSC
★ PPSC
★ 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))
Correct Answer: Option B — [False, True, True, False, False]
Detailed Academic Explanation:
[False, True, True, False, False] is the correct answer to “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))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 7 of 40
★ FPSC
★ PPSC
★ 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)
Correct Answer: Option A — 10 56
Detailed Academic Explanation:
10 56 is the correct answer to “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)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = ['ab', 'cd'] print(map(len, x))
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “What will be the output of the following Python code? x = ['ab', 'cd'] print(map(len, x))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How are required arguments specified in the function heading?
Correct Answer: Option D — identifier
Detailed Academic Explanation:
identifier is the correct answer to “How are required arguments specified in the function heading”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 10 of 40
★ FPSC
★ PPSC
★ 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))
Correct Answer: Option A — False
Detailed Academic Explanation:
False is the correct answer to “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))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is tail recursion?
Correct Answer: Option D — A function where the recursive call is the last thing executed by the function
Detailed Academic Explanation:
A function where the recursive call is the last thing executed by the function is the correct answer to “What is tail recursion”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = ['ab', 'cd'] print(list(map(len, x)))
Correct Answer: Option B — [2, 2]
Detailed Academic Explanation:
[2, 2] is the correct answer to “What will be the output of the following Python code? x = ['ab', 'cd'] print(list(map(len, x)))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 13 of 40
★ FPSC
★ PPSC
★ 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)
Correct Answer: Option B — world hello hello
Detailed Academic Explanation:
world hello hello is the correct answer to “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)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 14 of 40
★ FPSC
★ PPSC
★ 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)
Correct Answer: Option C — 4 12
Detailed Academic Explanation:
4 12 is the correct answer to “What will be the output of the following Python code? x=12 def f1(a,b=x): print(a,b) x=15 f1(4)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 15 of 40
★ FPSC
★ PPSC
★ 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)))
Correct Answer: Option C — error
Detailed Academic Explanation:
error is the correct answer to “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)))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 16 of 40
★ FPSC
★ PPSC
★ 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))
Correct Answer: Option D — 17
Detailed Academic Explanation:
17 is the correct answer to “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))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 17 of 40
★ FPSC
★ PPSC
★ 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)))
Correct Answer: Option C — error
Detailed Academic Explanation:
error is the correct answer to “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)))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 18 of 40
★ FPSC
★ PPSC
★ 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)))
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “The output of the following codes are the same. [x**2 for x in range(10)] list(map((lambda x:x**2), range(10)))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = [12.1, 34.0] print(len(' '.join(list(map(str, x)))))
Correct Answer: Option C — 9
Detailed Academic Explanation:
9 is the correct answer to “What will be the output of the following Python code? x = [12.1, 34.0] print(len(' '.join(list(map(str, x)))))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the base case in the Merge Sort algorithm when it is solved recursively?
Correct Answer: Option C — A list of length one
Detailed Academic Explanation:
A list of length one is the correct answer to “What is the base case in the Merge Sort algorithm when it is solved recursively”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 21 of 40
★ FPSC
★ PPSC
★ 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)
Correct Answer: Option A — 100
Detailed Academic Explanation:
100 is the correct answer to “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)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
. . . . . . . . returns a dictionary of the module namespace. . . . . . . . . returns a dictionary of the current namespace.
Correct Answer: Option C — globals() locals()
Detailed Academic Explanation:
globals() locals() is the correct answer to “. . . . . . . . returns a dictionary of the module namespace. . . . . . . . . returns a dictionary of the current namespace.”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used for function?
Correct Answer: Option C — def
Detailed Academic Explanation:
def is the correct answer to “Which keyword is used for function”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = ['ab', 'cd'] print(len(map(list, x)))
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “What will be the output of the following Python code? x = ['ab', 'cd'] print(len(map(list, x)))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can you define a function that accepts both positional and keyword arguments?
Correct Answer: Option A — By using both *args and **kwargs
Detailed Academic Explanation:
By using both *args and **kwargs is the correct answer to “How can you define a function that accepts both positional and keyword arguments”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If a function doesn't have a return statement, which of the following does the function return?
Correct Answer: Option C — None
Detailed Academic Explanation:
None is the correct answer to “If a function doesn't have a return statement, which of the following does the function return”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: square = lambda x: x**2 result = square(5) print(result)
Correct Answer: Option A — 25
Detailed Academic Explanation:
25 is the correct answer to “What is the output of the following code: square = lambda x: x**2 result = square(5) print(result)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? lamb = lambda x: x ** 3 print(lamb(5))
Correct Answer: Option C — 125
Detailed Academic Explanation:
125 is the correct answer to “What will be the output of the following Python code? lamb = lambda x: x ** 3 print(lamb(5))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = [12, 34] print(len(list(map(int, x))))
Correct Answer: Option A — 2
Detailed Academic Explanation:
2 is the correct answer to “What will be the output of the following Python code? x = [12, 34] print(len(list(map(int, x))))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = ['ab', 'cd'] print(list(map(upper, x)))
Correct Answer: Option C — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “What will be the output of the following Python code? x = ['ab', 'cd'] print(list(map(upper, x)))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = 'abcd' print(list(map([], x)))
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “What will be the output of the following Python code? x = 'abcd' print(list(map([], x)))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 32 of 40
★ FPSC
★ PPSC
★ 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)
Correct Answer: Option A — 432
Detailed Academic Explanation:
432 is the correct answer to “What will be the output of the following Python code? def f(x, y, z): return x + y + z f(2, 30, 400)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 33 of 40
★ FPSC
★ PPSC
★ 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)
Correct Answer: Option B — x is 50 Changed global x to 2 Value of x is 2
Detailed Academic Explanation:
x is 50 Changed global x to 2 Value of x is 2 is the correct answer to “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)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many keyword arguments can be passed to a function in a single function call?
Correct Answer: Option C — zero or more
Detailed Academic Explanation:
zero or more is the correct answer to “How many keyword arguments can be passed to a function in a single function call”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Only problems that are recursively defined can be solved using recursion.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “Only problems that are recursively defined can be solved using recursion.”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is a variable defined inside a function referred to as?
Correct Answer: Option C — A local variable
Detailed Academic Explanation:
A local variable is the correct answer to “What is a variable defined inside a function referred to as”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 37 of 40
★ FPSC
★ PPSC
★ 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)
[0, None, 1, None, 2, None] is the correct answer to “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)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? def foo(k): k = [1] q = [0] foo(q) print(q)
Correct Answer: Option A — [0]
Detailed Academic Explanation:
[0] is the correct answer to “What will be the output of the following Python code? def foo(k): k = [1] q = [0] foo(q) print(q)”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = [12, 34] print(len(''.join(list(map(int, x)))))
Correct Answer: Option C — error
Detailed Academic Explanation:
error is the correct answer to “What will be the output of the following Python code? x = [12, 34] print(len(''.join(list(map(int, x)))))”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
On assigning a value to a variable inside a function, it automatically becomes a global variable.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “On assigning a value to a variable inside a function, it automatically becomes a global variable.”. This question is standard in competitive examination syllabi for Functions In Python.
💡Key Conceptual Anchor:Functions In Python
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡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.