
🎓 हर हाथ कंप्यूटर, हर हाथ रोज़गार
45 important O Level M3-R5.1 (Python) MCQ questions with answers and explanations — 5 from each of the 9 chapters, every code question run in real Python — plus chapter tips, Python traps, a 3-week plan and a free M3-R5 online test.
Zed-King Group of Institute
Zed-King Group of Institute

M3-R5.1 — Programming and Problem Solving through Python is the module that decides most O Level results. The other theory papers reward reading; M3 rewards tracing code. A large share of its questions show a few lines of Python and ask for the output — and the options are built from the mistakes students make when they read code too fast.
This page gives you 45 important O Level M3 Python MCQ questions with answers — five from each of the nine chapters — with a one-line explanation for every answer. Every code question on this page was run in real Python before publishing, so the answers are the ones the computer actually prints. When you finish, take the free M3-R5 online test: 10 full sets of 50 questions in 45 minutes, graded on the NIELIT S–F scale. You can also paste any code from this page into our free online Python compiler and run it yourself.
Zed-King Group of Institute, Kaithal is a NIELIT Study Centre (ACCR-O3292) under the Ministry of Electronics & IT, Government of India, teaching O Level since 2006.
What This Page Covers
Item | Detail |
|---|---|
Module | M3-R5.1 — Programming and Problem Solving through Python |
Chapters | 9 (Programming basics, Flowcharts, Python basics, Operators, Sequence types, Functions, Files, Scope & Modules, NumPy) |
MCQs on this page | 45 — 5 per chapter, with answer and explanation (19 code questions checked by running them) |
Practical paper for this module | PR-3 (Python programs on a computer) |
Passing marks | 50% in the module, separately from the practical |
Free online test | 10 sets × 50 questions, 45 minutes, instant result with explanations |
How to Use These 45 Questions
Cover the answer and trace the code on paper first. Write the value of every variable after each line. This is exactly the skill the exam tests.
Then run it. Copy the code into the Python compiler and compare. Every time your paper answer and the real output differ, you have found a rule you did not know.
Read the explanation even when you were right — the exam will ask the same idea with different numbers.
Finish with a timed test. 50 questions against a clock is a different skill from 45 questions at your own pace.
Chapter-wise Weight in Our M3 Question Bank
Our M3 question bank has 500 questions. They are not spread evenly: operators, sequence data types and functions together hold about half of them. Those three chapters are also where almost all the "what is the output" questions come from.
Chapter | Topic | Questions in our bank | What is asked most |
|---|---|---|---|
1 | Introduction to Programming | 45 | Compiler vs interpreter, languages, algorithm basics, complexity |
2 | Algorithms and Flowcharts | 18 | Flowchart symbols, simple algorithms |
3 | Introduction to Python | 68 | print() and input(), data types, identifiers, keywords |
4 | Operators, Expressions & Statements | 73 | Operator precedence, / vs //, bitwise, if/loops, break/continue |
5 | Sequence Data Types | 96 | Slicing, list/tuple/set/dict methods, mutability |
6 | Functions | 78 | Return values, arguments, recursion, local vs global |
7 | File Processing | 41 | File modes, read/write methods, seek and tell |
8 | Scope and Modules | 35 | LEGB, global, import styles, math/random/os |
9 | NumPy Basics | 25 | ndarray, arange, zeros/ones, shape, reshape |
Chapter 1 — Introduction to Programming (5 MCQs)
Q1. Who developed Python programming language?
(A) Dennis Ritchie
(B) James Gosling
(C) Guido van Rossum
(D) Bjarne Stroustrup
✅ Answer: (C) Guido van Rossum — Python was created by Guido van Rossum and released in 1991.
Q2. ______translator is used to convert assembly language into machine language.
(A) Interpreter
(B) Assembler
(C) Compiler
(D) Linker
✅ Answer: (B) Assembler — An assembler translates assembly language instructions into machine code.
Q3. The complexity of linear search algorithm is_______
(A) O(1)
(B) O(log n)
(C) O(n^2)
(D) O(n)
✅ Answer: (D) O(n) — Linear search examines each element sequentially until the target is found or list ends, giving worst‑case time proportional to n.
Q4. What are the three basic constructs used to build an algorithm?
(A) Sequence,selection,repeat
(B) Array, pointer, structure
(C) Loop, branch, call
(D) Input, process, output
✅ Answer: (A) Sequence,selection,repeat — Algorithms are built using sequential execution, conditional selection, and repeated looping structures.
Q5. Which error occurs when you run this code (mango is not defined anywhere)?
apple = mango(A) NameError
(B) TypeError
(C) SyntaxError
(D) ValueError
✅ Answer: (A) NameError — Referencing a name that has not been defined raises a NameError exception.
💡 Chapter tip: Know the translators by job: a compiler converts the whole program, an interpreter runs it line by line, an assembler converts assembly to machine code. Add the basics of algorithms — sequence, selection, iteration — and the common complexities: O(n) for linear search, O(log n) for binary search.
Chapter 2 — Algorithms and Flowcharts (5 MCQs)
Q6. Which symbol is used for input and output operations in a flowchart?
(A) Rounded rectangle
(B) Trapezoid
(C) Parallelogram
(D) Ellipse
✅ Answer: (C) Parallelogram — A parallelogram shape denotes input and output operations in standard flowchart symbols.
Q7. What does a diamond symbol in a flowchart represent?
(A) Loop
(B) Input
(C) Function
(D) Decision/Condition
✅ Answer: (D) Decision/Condition — Used to represent conditional logic (e.g., if, elif, else in Python).
Q8. In a flowchart, what does an oval represent?
(A) Condition
(B) Start/End
(C) Loop
(D) Input/Output
✅ Answer: (B) Start/End — An oval in a flowchart indicates the start or end point of the process.
Q9. What does a rectangle symbol in a flowchart represent?
(A) Process
(B) Decision
(C) Start/End
(D) Input/Output
✅ Answer: (A) Process — A rectangle represents a process or instruction like a calculation or assignment in Python (e.g., x = 5 + 2).
Q10. What is the full form of GCD?
(A) General computing device
(B) Global code directory
(C) Greatest common denominator
(D) Greatest common divisor
✅ Answer: (D) Greatest common divisor — GCD stands for the greatest common divisor, the largest integer that divides two numbers without remainder.
💡 Chapter tip: Learn the five symbols by heart — oval (start/end), parallelogram (input/output), rectangle (process), diamond (decision) and arrows (flow). Then draw flowcharts for the classic problems: largest of three numbers, even/odd, factorial, prime check and GCD.
Chapter 3 — Introduction to Python (5 MCQs)
Q11. In Python, ___ defines a block of statements.
(A) Quotation marks ""
(B) Indentation
(C) Brackets {}
(D) Parentheses ()
✅ Answer: (B) Indentation — Indentation determines the grouping of statements that belong to the same block.
Q12. The default separator character of print() is ______
(A) space
(B) comma
(C) newline
(D) tab
✅ Answer: (A) space — When print is called without specifying sep, it inserts a single space between the printed values.
Q13. Python converts the source code into an intermediate form called_____
(A) Source code
(B) Machine code
(C) Bytecode
(D) Object file
✅ Answer: (C) Bytecode — During execution Python compiles source code to bytecode, an intermediate representation executed by the virtual machine.
Q14. In Python 3, what is the data type of the expression int(m) / int(n)?
(A) int
(B) string
(C) float
(D) bool
✅ Answer: (C) float — Dividing two integers using int conversion produces a floating‑point result because Python performs true division.
Q15. What is the output of this code?
print('my_string'.isidentifier())(A) True
(B) Error
(C) False
(D) None
✅ Answer: (A) True — Isidentifier checks if a string follows identifier rules; my_string meets those rules so it returns True.
💡 Chapter tip: Most questions here are about print() and input(): print() separates values with a space (sep) and ends with a newline (end), and input() always returns a string. Also learn identifier rules, keywords, the basic data types and what type() returns.
Chapter 4 — Operators, Expressions and Python Statements (5 MCQs)
Q16. What are the values of these three expressions?
2**(3**2)
(2**3)**2
2**3**2(A) 64, 512, 64
(B) 512, 64, 512
(C) 512, 512, 512
(D) 64, 64, 64
✅ Answer: (B) 512, 64, 512 — 2 raised to 9 equals 512, (2 cubed) squared equals 64, and right‑associative exponentiation yields 512 again.
Q17. What is the value of this expression?
8/4/2, 8/(4/2)(A) (1.0, 1.0)
(B) (4.0, 4.0)
(C) (1.0, 4.0)
(D) (4.0. 1.0)
✅ Answer: (C) (1.0, 4.0) — 8 divided by 4 divided by 2 evaluates left‑to‑right giving 1.0, while 8 divided by (4 divided by 2) yields 4.0.
Q18. What is the output of this code? (Each number is printed on its own line.)
n = 5
while n > 0:
n -= 1
if n == 2:
continue
print(n)(A) 4310
(B) 5432
(C) 4210
(D) 4321
✅ Answer: (A) 4310 — The loop prints numbers 4,3,1,0 after skipping when n equals 2.
Q19. What does this expression evaluate to?
~4(A) -3
(B) -2
(C) -5
(D) -4
✅ Answer: (C) -5 — Bitwise NOT flips all bits of 4, resulting in the two's complement representation of -5.
Q20. What is the output of this expression?
min(max(False, -3, -4), 2, 7)(A) -4
(B) False
(C) -3
(D) 2
✅ Answer: (B) False — Max returns the greatest of False, -3, -4 which is False, and min compares False with 2 and 7 yielding False.
💡 Chapter tip: Output questions decide this chapter. Remember four rules: ** is evaluated right to left, / always gives a float, // gives the floor, and ~x equals -(x+1). For loops, trace break and continue on paper line by line — then run the code to check yourself.
Chapter 5 — Sequence Data Types (5 MCQs)
Q21. What will be stored in a after this code runs?
a = [1, 2, 3]
a[-3:-1] = 10, 20, 30, 40
print(a)(A) [10, 20, 30, 40, 3]
(B) [10, 20, 30, 40]
(C) IndexError
(D) [10, 20, 30, 40, 2, 3]
✅ Answer: (A) [10, 20, 30, 40, 3] — Assigning the slice replaces the two elements with four new ones, resulting in the list shown.
Q22. What is the output of this code?
t = (1, 2, 4, 3)
print(t[1:3])(A) (2, 4, 3)
(B) (1, 2)
(C) (1, 2, 4)
(D) (2, 4)
✅ Answer: (D) (2, 4) — Slicing a tuple from index 1 up to but not including index 3 yields the elements at positions 1 and 2 which are 2 and 4.
Q23. What is the output of this code?
nums = set([1, 1, 2, 3, 3, 3, 4])
print(len(nums))(A) 5
(B) 2
(C) 4
(D) 1
✅ Answer: (C) 4 — A set removes duplicates, leaving four distinct elements, so its length is 4.
Q24. What is the output of this code?
a = {4, 5, 6}
b = {2, 8, 6}
print(a - b)(A) {6}
(B) {4,5}
(C) Error as unsupported operand type for set data type
(D) Error as the duplicate item 6 is present in both sets
✅ Answer: (B) {4,5} — Set subtraction removes elements present in the second set, leaving only those unique to the first set.
Q25. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
(A) print(t[3])
(B) print(len(t))
(C) print(max(t))
(D) t[3] = 45
✅ Answer: (D) t[3] = 45 — Tuple elements cannot be reassigned, so attempting to assign a new value to an index raises a TypeError.
💡 Chapter tip: This is the biggest chapter in our question bank. Master slicing (the end index is never included, negative indexes count from the end), which types are mutable (list, dict, set) and which are not (string, tuple), and that a set keeps only unique values.
Chapter 6 — Functions (5 MCQs)
Q26. What is the output of this code?
def greet():
print("Hello")
x = greet()
print(x)(A) Hello
(B) Hello None
(C) None
(D) Error
✅ Answer: (B) Hello None — The function prints Hello and returns the default return value None, so printing the variable shows Hello followed by None.
Q27. What is the output of this code?
def foo(i, x=[]):
x.append(i)
return x
for i in range(3):
print(foo(i))(A) [1][1,2][1,2,3]
(B) [0][0,1][0,1,2]
(C) [0][1][2]
(D) [1][2][3]
✅ Answer: (B) [0][0,1][0,1,2] — The default list persists across calls, so successive calls produce [0], then [0,1], then [0,1,2].
Q28. What is the output of this code?
def test(i, j):
if i == 0:
return j
else:
return test(i - 1, i + j)
print(test(4, 7))(A) 17
(B) 4
(C) Infinite loop
(D) 7
✅ Answer: (A) 17 — Recursive calls reduce i to zero, accumulating sum; final result of test(4,7) equals 17.
Q29. What is the output of this code?
def a(b):
b = b + [5]
c = [1, 2, 3, 4]
a(c)
print(len(c))(A) 4
(B) An exception is thrown
(C) 5
(D) None of the above
✅ Answer: (A) 4 — The function modifies a local copy of the list, leaving the original list length unchanged at four.
Q30. What is the return type of this function?
def func1():
return 'mnp', 22(A) List
(B) Dictionary
(C) string
(D) tuple
✅ Answer: (D) tuple — The function returns two values separated by a comma, which Python packs into a tuple.
💡 Chapter tip: Know what a function returns when it has no return statement (None), the difference between local and global variables, default and keyword arguments, *args and **kwargs, and how recursion stops at a base case. The "mutable default argument" trap (Q27) is a favourite.
Chapter 7 — File Processing (5 MCQs)
Q31. What is the purpose of the 'a' mode in Python file handling?
(A) Archive file
(B) Access attributes
(C) Add new file
(D) Append data to a file
✅ Answer: (D) Append data to a file — Opening a file in append mode writes new data at the end without truncating existing contents.
Q32. What does readlines() return?
(A) A list of all lines in the file
(B) A single line as string
(C) The number of lines
(D) A generator object
✅ Answer: (A) A list of all lines in the file — Readlines reads the entire file and returns each line as an element in a list.
Q33. What happens if you call read() on a file that is already read to the end?
(A) Returns None
(B) Starts over
(C) Raises an error
(D) Returns empty string
✅ Answer: (D) Returns empty string — When the file pointer is at end‑of‑file, read() returns no characters, represented by an empty string.
Q34. Which file mode truncates (empties) an existing file when it is opened?
(A) t
(B) w
(C) f
(D) a
✅ Answer: (B) w — Opening a file with write mode truncates any existing content.
Q35. Which error does this code raise?
f = open("test.txt", "w")
f.write(345)(A) String Error
(B) Syntax error
(C) Run Time Error
(D) Type error
✅ Answer: (D) Type error — Writing a non‑string object to a file raises a type error because write expects a string argument.
💡 Chapter tip: Make a small table of modes: r (read, file must exist), w (write, empties the file first), a (append at the end), + for read and write together, b for binary. Then learn read(), readline(), readlines(), write(), writelines(), seek() and tell(), and why with open(...) closes the file for you.
Chapter 8 — Scope and Modules (5 MCQs)
Q36. How do you import a specific function from a module?
(A) include sqrt from math
(B) import math.sqrt
(C) from math import sqrt
(D) from math.sqrt import *
✅ Answer: (C) from math import sqrt — The import statement brings only the sqrt function from the math module into the current namespace.
Q37. What is the output of this code?
i = 0
def change(i):
i = i + 1
return i
change(1)
print(i)(A) 1
(B) 0
(C) An exception is thrown
(D) Nothing is displayed
✅ Answer: (B) 0 — The function modifies a local copy of i, leaving the global i unchanged, so printing i outputs 0.
Q38. What is the purpose of __name__ == "__main__" in Python modules?
(A) It prevents import errors
(B) It defines a module's name
(C) It checks if the module is being run directly
(D) It initializes the module
✅ Answer: (C) It checks if the module is being run directly — The condition evaluates true only when the script is executed as the main program, not when imported.
Q39. What is the output of this code?
from math import factorial
print(factorial(6))(A) 6
(B) 120
(C) 5040
(D) 720
✅ Answer: (D) 720 — The factorial function computes 6 factorial, which equals 720.
Q40. The statement from module import * imports all names from a module except those beginning with ______.
(A) Underscore(_)
(B) Asterisk (*)
(C) CapitalLetter
(D) Hyphen (-)
✅ Answer: (A) Underscore(_) — Import * brings in all module names except those that start with an underscore character.
💡 Chapter tip: Learn the LEGB order (Local, Enclosing, Global, Built-in), when you need the global keyword, the three ways to import (import math, from math import sqrt, import math as m) and what if __name__ == "__main__" is for. Know a few functions each from math, random, os and datetime.
Chapter 9 — NumPy Basics (5 MCQs)
Q41. What is the shape of np.array([[1, 2, 3], [4, 5, 6]])?
(A) (3, 2)
(B) (2,)
(C) (6,)
(D) (2, 3)
✅ Answer: (D) (2, 3) — The NumPy array has two rows and three columns, giving it a shape of (2, 3).
Q42. What is the output of np.arange(2, 10, 2)?
(A) [3, 5, 7, 9]
(B) [2, 10, 2]
(C) [2, 4, 6, 8]
(D) [2, 3, 4, 5, 6, 7, 8, 9]
✅ Answer: (C) [2, 4, 6, 8] — Arange generates numbers from 2 up to but not including 10 stepping by 2, producing [2,4,6,8].
Q43. What does np.zeros((2, 3)) return?
(A) A 3x2 array filled with 0s
(B) A 2x3 array filled with 0s
(C) A 1D array with 5 zeros
(D) A 2x3 array filled with 1s
✅ Answer: (B) A 2x3 array filled with 0s — Np.zeros creates a two‑by‑three NumPy array where every entry is zero.
Q44. What is the main object in NumPy?
(A) ndarray
(B) matrix
(C) dataframe
(D) series
✅ Answer: (A) ndarray — NumPy uses the ndarray object for multidimensional arrays.
Q45. Which attribute of a NumPy array returns the shape (dimensionality) of the array?
(A) ndim
(B) shape
(C) dimension
(D) size
✅ Answer: (B) shape — Shape attribute provides a tuple describing each dimension size of the NumPy array.
💡 Chapter tip: The core is the ndarray. Know how to create one (array, arange, zeros, ones, eye), its attributes (shape, ndim, size, dtype), reshape(), and that + - * / work element by element. Note that shape is an attribute — a.shape, not a.shape().
6 Python Traps That Cost Marks in M3
/ vs // — in Python 3, 7/2 is 3.5 and even 8/4 is 2.0 (a float). Only // gives a whole number.
** is right to left — 2**3**2 is 2**9 = 512, not 64.
The end of a slice is never included — t[1:3] gives items 1 and 2 only.
A function without return gives None — and a print() inside it still prints first.
A default list argument is created once — it keeps growing across calls (Q27).
Assigning inside a function makes a new local variable — the global one does not change unless you write global.
Practise Python Free — Test, Compiler and Programs
Everything below is free — no login, no fee, no registration:
Free M3-R5.1 online test — 10 sets, 50 questions each, 45 minutes, no negative marking, S–F grade and an explanation for every question.
Free online Python compiler — run any code from this page in your browser, with NumPy.
Python practice questions — a new program to write every time, checked automatically.
30 Python programs explained — step by step, with output.
M3 chapter-wise MCQ PDFs · M3 chapter-wise notes · M3 previous year papers · official M3 syllabus
Free PR-3 practical test — write real programs against the clock, run in real Python.
Start the Free M3-R5 Online Test
A 3-Week Plan for M3
Week 1: Chapters 1, 2 and 3. Short theory, many definition questions. Start writing tiny programs from day one — print, input, type conversion.
Week 2: Chapters 4, 5 and 6 — the heart of M3. Every day: 20 output questions on paper, then run them. Do one PR-3 program every day too.
Week 3, days 1–3: Chapters 7, 8 and 9 — file modes, scope rules, imports and NumPy basics.
Week 3, days 4–7: one full M3 online test every day. After each test, run every code question you got wrong and find the exact line where your tracing went wrong.
A score of 85% or more gives an S grade. In M3 the difference between B and S is almost always careful tracing, not more reading.
Learn Python and O Level at Zed-King Institute, Kaithal
Zed-King Group of Institute is a NIELIT Study Centre — ACCR-O3292 — Ministry of Electronics & IT, Government of India, running in Kaithal since 2006. Our students write and run Python in the lab every day, take weekly timed M3 tests and prepare the PR-3 practical with a teacher beside them.
Course | Fee | Duration |
|---|---|---|
NIELIT O Level (M1–M4 with all practicals) | ₹20,000 | 1 Year |
Python Programming | ₹7,000 | 3 Months |
Visit us at: Kaithal - Pundri - Karnal Rd, near New Bus Stand, opp. Hanuman Vatika, Friends Colony, Kaithal, Haryana 136027. Call +91-9416111612.
Join O Level Course — NIELIT Study Centre, Kaithal
Related Reading
Tags
Free for every student
O Level mock tests (M1–M4 theory and PR-1–PR-4 practical) with instant grading, plus free notes, PDFs and video classes for CCC, O Level and ECC. No fees, no registration.
FAQ
Share this Article
ZedKing Courses
NIELIT & Indian Govt. certified programmes, expert faculty, aur guaranteed career support.
More Like This