Introduction To Python — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Introduction To Python — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
35
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
42 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
35
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/35 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 35 questions answered.
Question 1 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python function? min(max(False,-3,-4), 2,7)
Correct Answer: Option D — False
Detailed Academic Explanation:
In Python, the boolean value False evaluates to 0 in numeric contexts. The max() function returns the largest of the given arguments. Here, we have the expression max(False, -3, -4) . Since False is equivalent to 0 , and -3 and -4 are numeric values, the largest value among them is 0 . Therefore, the output of max(False, -3, -4) is False . The min() function then evaluates min(False, 2, 7) , and since False evaluates to 0 and 2 and 7 are greater than 0 , the minimum value among them is False . Hence, the overall output is False .
💡Key Conceptual Anchor:Introduction To Python
Question 2 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python function? len(["hello",2, 4, 6])
Correct Answer: Option C — 4
Detailed Academic Explanation:
The len() function returns the number of items in an object. Here, we have a list ["hello", 2, 4, 6] . The list contains 4 items: a string, two integers, and another integer. Therefore, the output of len(["hello", 2, 4, 6]) will be 4 .
💡Key Conceptual Anchor:Introduction To Python
Question 3 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a core data type in Python programming?
Correct Answer: Option C — Class
Detailed Academic Explanation:
In Python, the core data types include: 1. Tuples 2. Lists 3. Dictionary However, Classes are not considered a core data type in Python. Classes are used to create user-defined data structures that bundle data attributes and methods. Therefore, the correct option is Option C: Class .
💡Key Conceptual Anchor:Introduction To Python
Question 4 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following is not a keyword in Python language?
Correct Answer: Option B — eval
Detailed Academic Explanation:
In Python, keywords are reserved identifiers that have special meanings and purposes within the language. eval is not a keyword in Python; rather, it is a built-in function used to evaluate a Python expression stored in a string. Keywords like pass , assert , and nonlocal have specific meanings in Python and are reserved for special purposes within the language. Therefore, the correct option is Option B: eval .
💡Key Conceptual Anchor:Introduction To Python
Question 5 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = [[0], [1]] print((' '.join(list(map(str, x))),))
Correct Answer: Option D — ('[0] [1]',)
Detailed Academic Explanation:
In the given code, the variable x is assigned a list containing two sublists: [[0], [1]] . The map() function is used to apply the str() function to each element of x , converting them to strings. Then, list() is used to convert the resulting map object to a list. The join() function concatenates these strings with a space separator. Finally, the result is enclosed in a tuple using (...) and printed. Therefore, the output will be: ('[0] [1]',) .
💡Key Conceptual Anchor:Introduction To Python
Question 6 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? def foo(): try: return 1 finally: return 2 k = foo() print(k)
Correct Answer: Option C — 2
Detailed Academic Explanation:
In the given code, the function foo() is defined. Inside the function, there is a try-finally block. In the try block, return 1 is encountered. However, before returning, the finally block executes, which contains return 2 . As per the behavior of finally , it always executes, regardless of whether there is an exception or not. Therefore, the return 2 statement in the finally block is executed, and 2 is returned from the function. When foo() is called and its return value is assigned to k , k will be 2 . Hence, the output will be 2 .
💡Key Conceptual Anchor:Introduction To Python
Question 7 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To add a new element to a list we use which Python command?
Correct Answer: Option C — list1.append(5)
Detailed Academic Explanation:
In Python, to add a new element to the end of a list, the append() method is used. The syntax for using append() is list_name.append(element) , where list_name is the name of the list and element is the value to be added. append() adds the specified element to the end of the list, increasing the list's length by one. Therefore, list1.append(5) will add the element 5 to the end of list1 .
💡Key Conceptual Anchor:Introduction To Python
Question 8 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The following python program can work with . . . . . . . . parameters. def f(x): def f1(*args, **kwargs): print("Examveda") return x(*args, **kwargs) return f1
Correct Answer: Option A — any number of
Detailed Academic Explanation:
The program defines a function f that takes another function x as an argument. Inside f , there is a nested function f1 defined with variable-length arguments *args and keyword arguments **kwargs . The use of *args allows f1 to accept any number of positional arguments, and **kwargs allows it to accept any number of keyword arguments. Inside f1 , "Examveda" is printed, and then the function x is called with the received arguments using (*args, **kwargs) . Therefore, the program can work with any number of parameters .
💡Key Conceptual Anchor:Introduction To Python
Question 9 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the maximum possible length of an identifier in Python?
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
In Python, there is no fixed limit on the maximum length of an identifier imposed by the language itself. Identifiers can be of any length as long as they follow the naming rules (e.g., start with a letter or underscore, followed by letters, digits, or underscores). However, extremely long identifiers are discouraged because they reduce code readability and may not be supported well by some tools or editors. Option A (79 characters) refers to the recommended maximum line length in PEP 8, not identifier length. Option B and C (31 and 63 characters) were limits in older languages like C, not Python. Therefore, the correct answer is Option D: none of the mentioned .
💡Key Conceptual Anchor:Introduction To Python
Question 10 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? i = 1 while True: if i%3 == 0: break print(i) i + = 1
Correct Answer: Option B — error
Detailed Academic Explanation:
Explanation: The code starts with `i` initialized to 1. The `while True` loop runs indefinitely until a `break` statement is encountered. Inside the loop, the `if i%3 == 0:` condition checks if `i` is divisible by 3. If `i` is divisible by 3, the `break` statement will terminate the loop. If `i` is not divisible by 3, the value of `i` is printed. Then, there's an error `i += 1` it should be not `i + = 1`. So the correct answer is Option B: error
💡Key Conceptual Anchor:Introduction To Python
Question 11 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a Python tuple?
Correct Answer: Option D — (1, 2, 3)
Detailed Academic Explanation:
(1, 2, 3) is the correct answer to “Which of the following is a Python tuple”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 12 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='')
Correct Answer: Option B — *abcde *
Detailed Academic Explanation:
*abcde * is the correct answer to “What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='')”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 13 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
Correct Answer: Option D — True
Detailed Academic Explanation:
True is the correct answer to “What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 14 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i)
Correct Answer: Option A — 4 3 2 1
Detailed Academic Explanation:
4 3 2 1 is the correct answer to “What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i)”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 15 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What arithmetic operators cannot be used with strings in Python?
Correct Answer: Option B — -
Detailed Academic Explanation:
- is the correct answer to “What arithmetic operators cannot be used with strings in Python”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 16 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is the truncation division operator in Python?
Correct Answer: Option B — //
Detailed Academic Explanation:
// is the correct answer to “Which of the following is the truncation division operator in Python”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 17 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The process of pickling in Python includes . . . . . . . .
Correct Answer: Option A — conversion of a Python object hierarchy into byte stream
Detailed Academic Explanation:
conversion of a Python object hierarchy into byte stream is the correct answer to “The process of pickling in Python includes . . . . . . . .”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 18 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the value of 'result' in following Python program? list1 = [1,2,3,4] list2 = [2,4,5,6] list3 = [2,6,7,8] result = list() result.extend(i for i in list1 if i not in (list2+list3) and i not in result) result.extend(i for i in list2 if i not in (list1+list3) and i not in result) result.extend(i for i in list3 if i not in (list1+list2) and i not in result)
Correct Answer: Option A — [1, 3, 5, 7, 8]
Detailed Academic Explanation:
[1, 3, 5, 7, 8] is the correct answer to “What will be the value of 'result' in following Python program? list1 = [1,2,3,4] list2 = [2,4,5,6] list3 = [2,6,7,8] result = list() result.extend(i for i in list1 if i not in (list2+list3) and i not in result) result.extend(i for i in list2 if i not in (list1+list3) and i not in result) result.extend(i for i in list3 if i not in (list1+list2) and i not in result)”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 19 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function is called when the following Python program is executed? f = foo() format(f)
Correct Answer: Option C — __str__()
Detailed Academic Explanation:
__str__() is the correct answer to “Which function is called when the following Python program is executed? f = foo() format(f)”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 20 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'])) z
{'a', 'b', 'c', 'p', 'q', 'san'} is the correct answer to “What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'])) z”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 21 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python expression if x=56.236? print("%.2f"%x)
Correct Answer: Option D — 56.24
Detailed Academic Explanation:
56.24 is the correct answer to “What will be the output of the following Python expression if x=56.236? print("%.2f"%x)”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 22 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? z=set('abc$de') 'a' in z
Correct Answer: Option B — True
Detailed Academic Explanation:
True is the correct answer to “What will be the output of the following Python code snippet? z=set('abc$de') 'a' in z”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 23 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which module in the python standard library parses options received from the command line?
Correct Answer: Option B — getopt
Detailed Academic Explanation:
getopt is the correct answer to “Which module in the python standard library parses options received from the command line”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 24 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>>list1 = [1, 3] >>>list2 = list1 >>>list1[0] = 4 >>>print(list2)
Correct Answer: Option C — [4, 3]
Detailed Academic Explanation:
[4, 3] is the correct answer to “What will be the output of the following Python code? >>>list1 = [1, 3] >>>list2 = list1 >>>list1[0] = 4 >>>print(list2)”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 25 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? x = 'abcd' for i in range(len(x)): print(i)
Correct Answer: Option D — 0 1 2 3
Detailed Academic Explanation:
0 1 2 3 is the correct answer to “What will be the output of the following Python code? x = 'abcd' for i in range(len(x)): print(i)”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 26 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python statement? >>>"a"+"bc"
Correct Answer: Option B — abc
Detailed Academic Explanation:
abc is the correct answer to “What will be the output of the following Python statement? >>>"a"+"bc"”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 27 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are the two main types of functions in Python?
Correct Answer: Option C — Built-in function & User defined function
Detailed Academic Explanation:
Built-in function & User defined function is the correct answer to “What are the two main types of functions in Python”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 28 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is output of print(math.pow(3, 2))?
Correct Answer: Option A — 9.0
Detailed Academic Explanation:
9.0 is the correct answer to “What is output of print(math.pow(3, 2))”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 29 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python program? def addItem(listParam): listParam += [1] mylist = [1, 2, 3, 4] addItem(mylist) print(len(mylist))
Correct Answer: Option A — 5
Detailed Academic Explanation:
5 is the correct answer to “What will be the output of the following Python program? def addItem(listParam): listParam += [1] mylist = [1, 2, 3, 4] addItem(mylist) print(len(mylist))”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 30 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following statements is used to create an empty set in Python?
Correct Answer: Option D — set()
Detailed Academic Explanation:
set() is the correct answer to “Which of the following statements is used to create an empty set in Python”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 31 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a feature of Python DocString?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Which of the following is a feature of Python DocString”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 32 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following Python statements will result in the output: 6? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Correct Answer: Option B — A[1][2]
Detailed Academic Explanation:
A[1][2] is the correct answer to “Which of the following Python statements will result in the output: 6? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 33 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))
Correct Answer: Option C — Hello foo and bin
Detailed Academic Explanation:
Hello foo and bin is the correct answer to “What will be the output of the following Python code? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 34 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp = tester(12) >>>print(temp.id)
Correct Answer: Option A — 12
Detailed Academic Explanation:
12 is the correct answer to “What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp = tester(12) >>>print(temp.id)”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To Python
Question 35 of 35
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python expression? round(4.576)
Correct Answer: Option C — 5
Detailed Academic Explanation:
5 is the correct answer to “What will be the output of the following Python expression? round(4.576)”. This question is standard in competitive examination syllabi for Introduction To Python.
💡Key Conceptual Anchor:Introduction To 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.