Skip to main content

Functions In Python — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Functions In Python — Part 1 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

How can you make a parameter optional in a Python function?

Question 2 of 40
★ FPSC ★ PPSC

How can you pass a variable number of keyword arguments to a function in Python?

Question 3 of 40
★ FPSC ★ PPSC

What does the return statement in a function do?

Question 4 of 40
★ FPSC ★ PPSC

Which of the following is NOT a valid function name in Python?

Question 5 of 40
★ FPSC ★ PPSC

What is the purpose of the def keyword in Python?

Question 6 of 40
★ FPSC ★ PPSC

What is the purpose of the pass statement in a function?

Question 7 of 40
★ FPSC ★ PPSC

What does the lambda keyword do when used in a function?

Question 8 of 40
★ FPSC ★ PPSC

What is the purpose of the global keyword do when used in a function?

Question 9 of 40
★ FPSC ★ PPSC

What is the purpose of the return statement in a function?

Question 10 of 40
★ FPSC ★ PPSC

What does the *args syntax in a function definition mean?

Question 11 of 40
★ FPSC ★ PPSC

What is the purpose of using recursion in a function?

Question 12 of 40
★ FPSC ★ PPSC

What is the output of the following code: def greet(name): print(f"Hello, {name}!") greet("Alice")

Question 13 of 40
★ FPSC ★ PPSC

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

Question 14 of 40
★ FPSC ★ PPSC

Where are the arguments received from the command line stored?

Question 15 of 40
★ FPSC ★ PPSC

What is the purpose of using the ** symbol in function argument unpacking?

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def sum(*args): '''Function returns the sum of all values''' r = 0 for i in args: r += i return r print sum.__doc__ print sum(1, 2, 3) print sum(1, 2, 3, 4, 5)

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? min = (lambda x, y: x if x < y else y) min(101*99, 102*98)

Question 18 of 40
★ FPSC ★ PPSC

The nested list undergoes shallow copy even when the list as a whole undergoes deep copy.

Question 19 of 40
★ FPSC ★ PPSC

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

Question 20 of 40
★ FPSC ★ PPSC

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

Question 21 of 40
★ FPSC ★ PPSC

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

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? l1=[1, 2, 3, [4]] l2=list(l1) id(l1)==id(l2)

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def display(b, n): while n > 0: print(b,end="") n=n-1 display('z',3)

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def foo(fname, val): print(fname(val)) foo(max, [1, 2, 3]) foo(min, [1, 2, 3])

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def cube(x): return x * x * x x = cube(3) print x

Question 26 of 40
★ FPSC ★ PPSC

What is the purpose of a docstring in a function?

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def f1(): global x x+=1 print(x) x=12 print("x")

Question 28 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? l1=[10, 20, 30] l2=l1 id(l1)==id(l2) l2=l1.copy() id(l1)==id(l2)

Question 29 of 40
★ FPSC ★ PPSC

How are keyword arguments specified in the function heading?

Question 30 of 40
★ FPSC ★ PPSC

Fill in the line of the following Python code for calculating the factorial of a number. def fact(num): if num == 0: return 1 else: return _____________________

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def fun(n): if (n > 100): return n - 5 return fun(fun(n+11)); print(fun(45))

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? list(map((lambda x:x**2), filter((lambda x:x%2==0), range(10))))

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following code: def my_function(a, b): return a / b result = my_function(4, 2) print(result)

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? a = [1, 2, 3, 4, 5] b = lambda x: (b (x[1:]) + x[:1] if x else []) print(b (a))

Question 35 of 40
★ FPSC ★ PPSC

Which of the following statements is false about recursion?

Question 36 of 40
★ FPSC ★ PPSC

Which of these is not true about recursion?

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? list(map((lambda x:x^2), range(10)))

Question 38 of 40
★ FPSC ★ PPSC

Which of these is false about a package?

Question 39 of 40
★ FPSC ★ PPSC

Lambda contains block of statements.

Question 40 of 40
★ FPSC ★ PPSC

What happens if the base condition isn't defined in recursive programs?

✓ 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 →