Unit 3: Data Structures, Classes, and Inheritance - Subjective Questions

CSR101 — Python Programming • Practice Questions with Detailed Answers

20 questions

1

Explain the creation, indexing, slicing, and manipulation of lists in Python. Illustrate your answer with suitable examples.

2

What is list comprehension? Explain its syntax and compare it with a conventional for loop using examples involving filtering and transformation.

3

Distinguish between lists and tuples in Python. Discuss their syntax, mutability, performance, and appropriate use cases.

4

Explain dictionaries and sets in Python, including their creation, manipulation, uniqueness rules, and mutability.

5

Explain the concepts of mutability, aliasing, shallow copying, and deep copying in Python. Use examples to show how changes affect nested data structures.

6

Describe the working of map(), filter(), and reduce() in Python. Provide examples and explain how they support functional programming.

7

What is a Cartesian product? Explain how it can be generated in Python using nested loops and itertools.product().

8

Discuss the purpose of the itertools module. Explain the use of at least four important functions with suitable examples.

9

Explain the functions enumerate() and zip(). Show how they can be used to process multiple sequences efficiently.

10

Explain eval() and exec() in Python. Compare their purposes, demonstrate their syntax, and discuss the security risks involved.

11

Define a class, object, attribute, method, and instance in Python. Explain how these concepts are related using a practical example.

12

What is a constructor in Python? Explain the role of __init__(), instance attributes, default values, and object initialization.

13

Differentiate between instance attributes, class attributes, instance methods, class methods, and static methods.

14

Explain inheritance in Python. Distinguish between a base class and a derived class, and describe the advantages of inheritance with an example.

15

What is method overriding? Explain how super() is used when redefining inherited methods.

16

Explain multiple inheritance in Python. Discuss method resolution order and demonstrate how super() works in a multiple-inheritance hierarchy.

17

Design a practical object-oriented program for managing student records. Explain the classes, attributes, constructors, methods, and inheritance used in your design.

18

What are decorators in Python? Explain their purpose, syntax, and working by developing a decorator that measures or displays function execution.

19

Explain generators in Python. Compare generators with ordinary functions and lists, and illustrate the use of yield with an example.

20

Develop and explain an object-oriented example using a base class, derived classes, method overriding, and a generator to process objects.