Unit 2: Data Types and OOP Concepts - Subjective Questions

CAP776 — Programming In Python • Practice Questions with Detailed Answers

20 questions

1

Define a Python string. Explain string immutability, indexing, and slicing with suitable examples.

2

Describe commonly used string operators and methods in Python. Illustrate their use with examples.

3

Explain Python lists and discuss their important characteristics, operations, and methods.

4

What is list comprehension? Explain its syntax and use it to generate and filter values.

5

Define a tuple in Python. Explain tuple creation, packing, unpacking, and the significance of tuple immutability.

6

Distinguish between lists and tuples in Python. State suitable applications of each.

7

Explain dictionaries in Python. Describe key-value storage, key restrictions, and important dictionary operations.

8

Describe dictionary traversal, dictionary comprehension, and nested dictionaries with suitable Python examples.

9

Define a set in Python and explain set operations such as union, intersection, difference, and symmetric difference.

10

Compare sets with lists and tuples. Explain membership testing, duplicate elimination, and frozen sets.

11

Explain the range type in Python. Describe its forms, parameters, and use in iteration.

12

Compare strings, lists, tuples, dictionaries, sets, and ranges based on ordering, mutability, duplicates, and access method.

13

What is object-oriented programming? Explain its major features and advantages in Python.

14

Explain classes, objects, constructors, instance attributes, and the self parameter with an example.

15

Define encapsulation. How are public, protected, and private members represented in Python?

16

Explain how properties support encapsulation in Python. Develop a class containing a validated property.

17

Define inheritance and explain single, multilevel, hierarchical, multiple, and hybrid inheritance.

18

Explain method overriding and the use of super() in inheritance with a suitable example.

19

What is the Method Resolution Order in Python? Explain its importance in multiple inheritance and the diamond inheritance problem.

20

Design an object-oriented Python program for a library that demonstrates encapsulation, inheritance, strings, lists, tuples, dictionaries, sets, and ranges. Explain the design.