Python Programming. Exam Pattern Objective
Python Programming. Exam Pattern Objective
: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me
7. The 'and' operator returns True only if both operands are True. (True/False) Answer: True.
8.The 'or' operator returns True only if both operands are True. (True/False)
• Answer: False. It returns True if at least one operand is True.
9. Type conversion is not allowed in Python. (True/False)
• Answer: False. Type conversion is allowed in Python.
10. The order of operations follows the PEMDAS rule. (True/False) Answer: True.
Multiple Choice Questions
1. Which of the following is used to store a value?
a) token b) comment c) variable d) operator • Answer: c) variable
2. Which data type is used for representing true or false values?
a) integer b) float c) string d) Boolean • Answer: d) Boolean
3. Which of the following is an immutable data type?
a) list b) tuple c) set d) dictionary • Answer: b) tuple
4. Which operator is used for integer division?
a) / b) % c) // d) • Answer: c) //
5. Which operator is used for logical AND?
a) and b) or c) not d) == • Answer: a) and
8. The `pop()` method can be used to remove an item from a set. (True/False) Answer: True.
9. Dictionaries use numerical indices to access items. (True/False)
• Answer: False. Dictionaries use keys to access items.
10.Slicing extracts a portion of a sequence. (True/False) Answer: True.
Multiple Choice Questions
1. Accessing characters in a string by their position is called:
a) slicing b) concatenation c) indexing d) repetition • Answer: c) indexing
2. Which of the following is a mutable data structure?
a) string b) tuple c) list d) set • Answer: c) list
3. Which of the following is an immutable data structure?
a) list b) tuple c) set d) dictionary • Answer: b) tuple
4. Which method is used to add an item to a set?
a) append b) insert c) add d) remove • Answer: c) add
5. Dictionaries use ____ to access items.
a) indices b) keys c) values d) positions • Answer: b) keys
6. The ____ clause is used to execute code if no exception occurs in the try block.
(else/except/finally) Answer: else
7. A ____ file stores data in human-readable format. (text/binary/csv) Answer: text
8. A ____ file stores data in a non-human-readable format. (binary/text/csv) Answer: binary
9. The ____ function is used to open a file. (open/read/write) Answer: open
10. The ____ function is used to close a file. (close/read/write) Answer: close
11. The ____ method is used to read the entire content of a file. (read/readline/readlines)
Answer: read
12. The ____ method is used to read a single line from a file. (readline/read/readlines)
Answer: readline
13. The ____ method is used to read all lines from a file into a list. (readlines/read/readline)
Answer: readlines
14. The ____ method is used to write data to a file. (write/read/append) Answer: write
15. The ____ mode is used to append data to an existing file. (append/write/read)
Answer: append
Match the Following
• Column A. • Column B
1. Syntax error. a. Used to catch exceptions
2. Exception. b. Errors detected during parsing
3. try block. c. Always executed
4. except block. d. Used to handle exceptions
5. finally block. e. Errors detected during execution
• Answer: 1-b, 2-e, 3-d, 4-a, 5-c
True/False (with Explanation)
1. Syntax errors are detected during program execution. (True/False)
• Answer: False. Syntax errors are detected during parsing.
2. Exceptions are detected during parsing of the code. (True/False)
• Answer: False. Exceptions are detected during program execution.
3. The `try` block is used to catch exceptions. (True/False)
• Answer: False. The `except` block is used to catch exceptions.
4. The `finally` block is always executed. (True/False) • Answer: True.
5. The `else` clause is used to execute code if an exception occurs in the `try` block.
(True/False) • Answer: False. The `else` clause is used to execute code if no exception
occurs in the `try` block.
6. A binary file stores data in human-readable format. (True/False)
• Answer: False. A text file stores data in human-readable format.
7. The `open()` function is used to close a file. (True/False)
• Answer: False. The `close()` function is used to close a file.
8. The `read()` method reads a single line from a file. (True/False)
• Answer: False. The `readline()` method reads a single line from a file.
9. The `readlines()` method reads all lines from a file into a list. (True/False) • Answer: True.
Provide By. Guddu Kumar Mehta
Mob No ..: 9031139302
Sub ….: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me
10. The `write()` method is used to read data from a file. (True/False)
Answer: False. The `write()` method is used to write data to a file.
Multiple Choice Questions
1. What type of errors are detected during parsing of the code?
a) Exceptions b) Syntax errors c) Logical errors d) Runtime errors Answer: b) Syntax errors
2. What type of errors are detected during program execution?
a) Syntax errors b) Logical errors c) Exceptions d) Parsing errors • Answer: c) Exceptions
3. Which block is used to handle exceptions?
a) except b) try c) finally d) else • Answer: b) try
4. Which block is always executed, whether an exception occurs or not?
a) try b) except c) else d) finally • Answer: d) finally
5. Which method is used to read the entire content of a file?
a) readline b) readlines c) write d) read • Answer: d) read