0% found this document useful (0 votes)
8 views

Python Programming. Exam Pattern Objective

Uploaded by

mkj12dkj43
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Python Programming. Exam Pattern Objective

Uploaded by

mkj12dkj43
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Sub ….

: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me

Unit 1: Basics of Python Programming Syntax


Fill in the Blanks (Options)
1. A name given to a memory location to store a value is called a ____.
(variable/token/comment)• Answer: variable
2. The left-hand side of an assignment statement is called the ____. (lvalue/rvalue/expression)
• Answer: lvalue
3. The right-hand side of an assignment statement is called the ____. (rvalue/lvalue/statement)
• Answer: rvalue
4. A line of text ignored by the interpreter is called a ____. (comment/token/variable)
• Answer: comment
5. The data type for whole numbers is ____. (integer/float/complex) • Answer: integer
6. The data type for numbers with decimal points is ____. (float/integer/complex) Answer: float
7. The data type for true or false values is ____. (Boolean/integer/string) • Answer: Boolean
8. A sequence of characters is called a ____. (string/list/tuple) • Answer: string
9. A mutable sequence of items is called a ____. (list/tuple/set) • Answer: list
10. An immutable sequence of items is called a ____. (tuple/list/set) Answer: tuple
11. A collection of key-value pairs is called a ____. (dictionary/set/list) Answer: dictionary
12. The operator used for exponentiation is ____. (/%/+) Answer:*•
13. The operator used for integer division is ____. (//////*) Answer: //
14. The operator used for logical AND is ____. (and/or/not) Answer: and
15. The operator used for logical OR is ____. (or/and/not) Answer: or
Match the Following
• Column A. • Column B
1. Integer. a. Sequence of characters
2. Float. b. Whole numbers
3. String. c. Immutable sequence
4. List. d. Mutable sequence
5. Tuple. e. Numbers with decimal points
• Answer: 1-b, 2-e, 3-a, 4-d, 5-c
True/False (with Explanation)
1. A variable can only store one value at a time. (True/False) • Answer: True.
2. Comments are executed by the interpreter. (True/False)
• Answer: False. Comments are ignored by the interpreter.
3. Statement: A string is a mutable data type. (True/False)
• Answer: False. A string is an immutable data type.
4. A list is an immutable data type. (True/False)
• Answer: False. A list is a mutable data type.
5. The % operator performs integer division. (True/False)
• Answer: False. The % operator gives the remainder of division; // performs integer division.
6. The operator performs exponentiation. (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

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

Unit 2: Conditional and Iterative Statements


Fill in the Blanks (Options)
1. The ____ statement executes code only if a condition is true. (if/while/for)
• Answer: if
2. The ____ statement executes one block of code if a condition is true and another if it's false.
(if-else/if/while) • Answer: if-else
3. The ____ statement is used for multi-way branching. (if-elif-else/if-else/while)
• Answer: if-elif-else
4. The ____ loop executes a block of code repeatedly as long as a condition is true.
(while/for/if) • Answer: while
5. The ____ loop iterates over a sequence. (for/while/if) • Answer: for
6. The ____ function generates a sequence of numbers. (range/len/print)
Answer: range
7. The statement terminates a loop prematurely. (break/continue/pass) Answer: break
8. The ____ statement skips the current iteration of a loop. (continue/break/pass)
Answer: continue
9. A loop inside another loop is called a loop. (nested/conditional/iterative)
Answer: nested
Match the Following
• Column A. • Column B
1. if statement. a. Executes code repeatedly based on a condition
2. if-else statement. b. Terminates a loop
3. while loop. c. Executes code if a condition is true
Provide By. Guddu Kumar Mehta
Mob No ..: 9031139302
Sub ….: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me

4. for loop. d. Executes code based on a condition


5. break statement. e. Iterates over a sequence
• Answer: 1-c, 2-d, 3-a, 4-e, 5-b
True/False (with Explanation)
1. The `if` statement always executes a block of code. (True/False)
• Answer: False. It executes only if the condition is true.
2. The `if-else` statement can have multiple `else` blocks. (True/False)
• Answer: False. It can have only one `else` block.
3. The `while` loop executes at least once. (True/False)
• Answer: False. It executes only if the condition is true at the beginning.
4. The `for` loop is used to iterate over a sequence. (True/False) • Answer: True.
5. The `continue` statement terminates a loop prematurely. (True/False)
• Answer: False. The `break` statement terminates a loop; `continue` skips the current
iteration.
6. A nested loop is a loop inside another loop. (True/False) • Answer: True.
7. The `range()` function generates a sequence of numbers. (True/False) • Answer: True.
8. The `if-elif-else` statement can have multiple `elif` blocks. (True/False) • Answer: True.
9. The `break` statement skips the current iteration of a loop. (True/False)
• Answer: False. The `continue` statement skips the current iteration.
10. The `if` statement can have multiple `elif` blocks. (True/False) Answer: True.
Multiple Choice Questions
1. Which statement executes code only if a condition is true?
a) while b) for c) if d) else • Answer: c) if
2. Which statement executes one block of code if a condition is true and another if it's false?
a) if b) while c) if-else d) for • Answer: c) if-else
3. Which loop executes a block of code repeatedly as long as a condition is true?
a) for b) if c) while d) if-else • Answer: c) while
4. Which statement terminates a loop prematurely?
a) continue b) break c) pass d) if • Answer: b) break
5. Which function generates a sequence of numbers?
a) len b) print c) range d) input • Answer: c) range

Unit 3: String, List, Tuples, Set, and Dictionary

Fill in the Blanks (Options)


1. Accessing individual characters in a string using their position is called ____.
(indexing/slicing/concatenation) • Answer: indexing
2. Combining two strings is called ____. (concatenation/repetition/slicing)
• Answer: concatenation
3. Repeating a string multiple times is called ____. (repetition/concatenation/membership)
• Answer: repetition
Provide By. Guddu Kumar Mehta
Mob No ..: 9031139302
Sub ….: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me

4. Checking if a substring exists within a string is called ____. (membership/slicing/indexing)


• Answer: membership
5. Extracting a portion of a string is called ____. (slicing/concatenation/repetition)
• Answer: slicing
6. Combining two lists is called ____. (concatenation/repetition/membership)
Answer: concatenation
7. Repeating a list multiple times is called ____. (repetition/concatenation/membership)
Answer: repetition
8. Checking if an element exists within a list is called ____. (membership/slicing/indexing)
Answer: membership
9. Extracting a portion of a list is called ____. (slicing/concatenation/repetition)
Answer: slicing
10. Tuples are ____ data structures. (immutable/mutable/ordered)
Answer: immutable
11. Sets are ____ collections of unique items. (unordered/ordered/mutable)
Answer: unordered
12. Adding a new item to a set is done using the ____ method. (add/append/insert)
Answer: add
13. Removing an item from a set is done using the ____ method. (remove/delete/pop)
Answer: remove
14. Dictionaries are collections of ____ pairs. (key-value/index-value/item-value)
Answer: key-value
15. Dictionaries are ____ data structures. (mutable/immutable/ordered) Answer: mutable
Match the Following
• Column A. • Column B
1. Indexing. a. Extracting a portion of a sequence
2. Concatenation. b. Accessing elements using position
3. Slicing. c. Combining two sequences
4. Set. d. Collection of key-value pairs
5. Dictionary. e. Collection of unique items
• Answer: 1-b, 2-c, 3-a, 4-e, 5-d
True/False (with Explanation)
1. Strings are mutable data types. (True/False) • Answer: False. Strings are immutable.
2. Lists are immutable data types. (True/False) • Answer: False. Lists are mutable.
3. Tuples are mutable data types. (True/False) • Answer: False. Tuples are immutable.
4. Sets are ordered collections. (True/False) • Answer: False. Sets are unordered collections.
5. Dictionaries are immutable data structures. (True/False) •
Answer: False. Dictionaries are mutable.
6. The `append()` method is used to add an item to a set. (True/False)
• Answer: False. The `add()` method is used to add an item to a set.
7. The `remove()` method is used to remove an item from 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

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

Unit 4: Python Functions, Modules, and Packages


Fill in the Blanks (Options)
1. Functions that are built into Python are called ____ functions. (built-in/user-defined/module)
• Answer: built-in
2. Functions defined within a module are called ____ functions. (module/built-in/user-defined)
• Answer: module
3. Functions created by the programmer are called ____ functions.
(user-defined/built-in/module) • Answer: user-defined
4. Values passed to a function when it is called are called ____.
(arguments/parameters/variables) • Answer: arguments
5. Variables defined inside a function have ____ scope. (local/global/module) • Answer: local
6. Variables defined outside a function have ____ scope. (global/local/module) Answer: global
7. A function that can be defined in a single line is called a ____ function.
(lambda/recursive/module) Answer: lambda
8. A ____ is a file containing Python definitions and statements. (module/package/library)
Answer: module
9. A ____ is a collection of modules. (package/module/library) Answer: package
10. The keyword used to import a module is ____. (import/include/use) Answer: import
11. ____ are used to search for patterns in text. (Regular expressions/exceptions/modules)
Answer: Regular expressions
12. ____ are used to handle errors during program execution. (Exceptions/modules/packages)
Answer: Exceptions
13. ____ is the Python Package Index. (PyPI/Pip/PyLib) Answer: PyPI
14. ____ is the Python package manager. (Pip/PyPI/PyLib) Answer: Pip

Provide By. Guddu Kumar Mehta


Mob No ..: 9031139302
Sub ….: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me

15. A collection of modules and packages is called a ____. (library/module/package)


Answer: library
Match the Following
• Column A. • Column B
1. Built-in function. a. Value passed to a function
2. User-defined function. b. Scope within a function
3. Argument. c. Predefined function
4. Local scope. d. File containing Python definitions
5. Module e. Function created by the programmer
• Answer: 1-c, 2-e, 3-a, 4-b, 5-d
True/False (with Explanation)
1. Built-in functions are defined by the user. (True/False)
• Answer: False. They are predefined in Python.
2. Arguments are defined in the function definition. (True/False)
• Answer: False. Parameters are defined in the function definition; arguments are passed
when the function is called.
3. Variables defined inside a function have global scope. (True/False)
• Answer: False. They have local scope.
4. Variables defined outside a function have local scope. (True/False)
• Answer: False. They have global scope.
5. Lambda functions can be defined using the `def` keyword. (True/False)
• Answer: False. They are defined using the `lambda` keyword.
6. A module is a collection of packages. (True/False)
• Answer: False. A package is a collection of modules.
7. The `import` statement is used to include a module in a program. (True/False) Answer: True.
8.Regular expressions are used to handle errors during program execution. (True/False)
• Answer: False. Regular expressions are used to search for patterns in text.
9. Exceptions are used to search for patterns in text. (True/False)
• Answer: False. Exceptions are used to handle errors during program execution.
10. Pip is the Python Package Index. (True/False)
Answer: False. PyPI is the Python Package Index; Pip is the Python package manager.
Multiple Choice Questions
1. Functions that are built into Python are called:
a) user-defined functions b) module functions c) built-in functions d) recursive functions
• Answer: c) built-in functions
2. Values passed to a function when it is called are called:
a) parameters b) variables c) arguments d) keywords • Answer: c) arguments
3. Variables defined inside a function have:
a) global scope b) local scope c) module scope d) class scope • Answer: b) local scope
4. A function that can be defined in a single line is called a:
a) recursive function b) module function c) lambda function d) user-defined function
Provide By. Guddu Kumar Mehta
Mob No ..: 9031139302
Sub ….: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me

• Answer: c) lambda function


5. Which keyword is used to import a module?
a) include b) use c) import d) from • Answer: c) import

Unit 5: Object-Oriented Programming (OOP)


Fill in the Blanks (Options)
1. is the concept of hiding implementation details. (Abstraction/Encapsulation/Inheritance)
• Answer: Abstraction
2. is the concept of bundling data and methods that operate on the data.
(Encapsulation/Abstraction/Polymorphism) • Answer: Encapsulation
3. A is a blueprint for creating objects. (class/object/method) • Answer: class
4. An is an instance of a class. (object/class/method) • Answer: object
5. A method is bound to the class and not the object. (class/static/instance) • Answer: class
6. A method is not bound to either the class or the object. (static/class/instance)
Answer: static
7. A ____ is a special method that initializes an object. (constructor/destructor/method)
Answer: constructor
8. A is a special method that is called when an object is destroyed.
(destructor/constructor/method) Answer: destructor
9. ____ is the concept of creating a new class from an existing class.
(Inheritance/Polymorphism/Abstraction) Answer: Inheritance
10. A class that inherits from another class is called a class. (child/parent/base) Answer: child
11. A class that is inherited from is called a ____ class. (parent/child/derived) Answer: parent
12. is the ability of an object to take on many forms. (Polymorphism/Inheritance/Encapsulation)
Answer: Polymorphism
13. ____ is when a method in a subclass has the same name as a method in its superclass.
(method overriding/method overloading/method abstraction) Answer: method overriding
14. is when a class has multiple methods with the same name but different parameters.
(method overloading/method overriding/method abstraction) Answer: method overloading
15. A class variable is shared by ____ of the class. (all objects/only one object/no object)
Answer: all objects
Match the Following
• Column A. • Column B
1. Abstraction. a. Bundling data and methods
2. Encapsulation. b. Blueprint for creating objects
3. Class. c. Hiding implementation details
4. Object. d. Instance of a class
5. Inheritance. e. Creating a new class from an existing class
• Answer: 1-c, 2-a, 3-b, 4-d, 5-e
True/False (with Explanation)
1. Abstraction is the concept of bundling data and methods. (True/False)
Provide By. Guddu Kumar Mehta
Mob No ..: 9031139302
Sub ….: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me

• Answer: False. Encapsulation is the concept of bundling data and methods.


2. An object is a blueprint for creating classes. (True/False)
• Answer: False. A class is a blueprint for creating objects.
3. A class method is bound to the object. (True/False)
• Answer: False. A class method is bound to the class.
4. A static method is bound to the class. (True/False)
• Answer: False. A static method is not bound to either the class or the object.
5. A constructor initializes an object. (True/False) • Answer: True.
6. A destructor is called when an object is created. (True/False)
• Answer: False. It is called when an object is destroyed.
7. Inheritance is the ability of an object to take on many forms. (True/False)
• Answer: False. Polymorphism is the ability of an object to take on many forms.
8. Method overriding is when a method in a subclass has the same name as a method in its
superclass. (True/False) • Answer: True.
9. Method overloading is when a class has multiple methods with the same name but different
parameters. (True/False) • Answer: True.
10. A class variable is unique to each object of the class. (True/False)
Answer: False. A class variable is shared by all objects of the class.
Multiple Choice Questions
1. Which concept hides implementation details?
a) Encapsulation b) Inheritance c) Abstraction d) Polymorphism • Answer: c) Abstraction
2. Which concept bundles data and methods that operate on the data?
a) Inheritance b) Polymorphism c) Encapsulation d) Abstraction Answer: c) Encapsulation
3. A blueprint for creating objects is called a:
a) object b) method c) class d) function • Answer: c) class
4. A method that is bound to the class and not the object is called a:
a) static method b) instance method c) class method d) object method
Answer: c) class method
5. What is the concept of creating a new class from an existing class called?
a) Polymorphism b) Encapsulation c) Abstraction d) Inheritance • Answer: d) Inheritance

Unit 6: Exception and File Handling in Python


Fill in the Blanks (Options)
1. ____ are errors detected during parsing of the code. (Syntax errors/Exceptions/Logical
errors) • Answer: Syntax errors
2. ____ are errors detected during program execution. (Exceptions/Syntax errors/Logical
errors) • Answer: Exceptions
3. The ____ block is used to handle exceptions. (try/except/finally) • Answer: try
4. The ____ block is used to catch exceptions. (except/try/finally) • Answer: except
5. The ____ block is always executed, whether an exception occurs or not. (finally/try/except)
• Answer: finally
Provide By. Guddu Kumar Mehta
Mob No ..: 9031139302
Sub ….: Python Programming
Sem ..: 2nd
By. Guddu Kumar Mehta
WhatsApp No ..: Message Me

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

Provide By. Guddu Kumar Mehta


Mob No ..: 9031139302

You might also like