FINAL EXAMINATION *200 Questions Covering
Core Syntax, Data Structures, OOP, File Handling,
Exceptions, and Advanced Built-ins* (Guaranteed
pass )
INTRODUCTION
This final examination is designed to rigorously assess your mastery of Python programming
fundamentals and advanced features. The exam consists of 200 multiple-choice questions, each
carefully crafted to test both theoretical knowledge and practical understanding of Python’s
behavior.
Topics Covered:
1. Syntax, Variables, and Data Types (Q1–20) – Identifiers, mutability, type conversion,
truthiness.
2. Control Flow (Q21–40) – Loops, conditionals, break, continue, else clauses.
3. Functions and Scope (Q41–60) – def, lambda, return, global/nonlocal, decorators, recursion.
4. Data Structures (Q61–100) – Lists, tuples, dictionaries, sets, comprehensions, copying,
methods.
5. File Handling and Exceptions (Q101–120) – open, modes, with context, try-except-else-
finally, raise.
, 6. Object-Oriented Programming (Q121–140) – Classes, self,
inheritance, super(), @staticmethod, @classmethod, special methods.
7. Modules, Built-ins, and Advanced (Q141–160) – import, sys, datetime, random, re, json,
generators, itertools.
8. Common Built-in Functions (Q161–180) – map, filter, zip, enumerate, all, any, sorted, pow.
9. Exceptions and Debugging (Q181–200) – raise, assert, custom exceptions, tracebacks,
chaining.
Section 1: Syntax, Variables, and Data Types (Q1–20)
1. What is the output of print(type(10))?
A. <class 'int'>
B. <class 'float'>
Rationale: 10 is an integer literal, so type() returns int.
2. Which of the following is a valid variable name in Python?
A. _my_var
B. 2var
Rationale: Variable names cannot start with a digit; underscore is allowed.
3. What is the result of 3 * 'hi'?
A. 'hihihi'
B. 'hi hi hi'
Rationale: The * operator repeats a string, concatenating it N times.
4. Which data type is immutable?
A. tuple
B. list
Rationale: Tuples cannot be changed after creation; lists are mutable.
5. What does bool([]) return?
A. False
, B. True
Rationale: Empty sequences are falsy in Python.
6. What is the output of print(5 // 2)?
A. 2
B. 2.5
Rationale: // is floor division; it returns an integer result.
7. Which operator checks if two objects are the same object in memory?
A. is
B. ==
Rationale: is compares identity; == compares value.
8. What is the type of None?
A. NoneType
B. None
Rationale: None is a singleton of NoneType.
9. Which converts a float to an integer?
A. int(3.14)
B. float(3.14)
Rationale: int() truncates toward zero.
10. What is the output of print(0.1 + 0.2 == 0.3)?
A. False
B. True
Rationale: Floating-point precision can cause small errors, so equality fails.
11. Which creates a complex number?
A. complex(1, 2)
B. complex("1+2j")
Rationale: Both are valid, but complex(1,2) is direct.
12. What is the value of len(range(5))?
A. 5
, B. 4
Rationale: range(5) generates numbers 0..4, length 5.
13. Which statement creates an empty set?
A. set()
B. {}
Rationale: {} creates an empty dict; set() is empty set.
14. What does "hello".capitalize() return?
A. 'Hello'
B. 'HELLO'
Rationale: capitalize() makes first letter uppercase, rest lowercase.
15. Which is a valid way to swap a and b?
A. a, b = b, a
B. a = b; b = a
Rationale: Tuple unpacking allows simultaneous assignment.
16. What is the result of type(range(5))?
A. <class 'range'>
B. <class 'list'>
Rationale: range is its own immutable sequence type.
17. Which operation raises a TypeError?
A. '5' + 3
B. 5 + 3
Rationale: Cannot concatenate string and int without conversion.
18. Which is not a valid Python numeric type?
A. decimal
B. int
Rationale: decimal requires import; int, float, complex are built-in.
19. What does chr(65) return?
A. 'A'