[Link].
(Computer Science and Engineering)
Semester–IV
Subject: Python Programming (BCO081B)
Marks: 64
Assignment #4
Section–A (5×2 = 10 Marks)
1. Define a class and an object with an example.
2. What is the use of the self parameter in Python classes?
3. Differentiate between constructor (__init__()) and destructor (__del__()).
4. Explain private variables in Python with an example.
5. What is the purpose of using raw strings (r"") in regular expressions?
Section–B (7×3=21 Marks)
1. Explain the role of parentheses in regular expressions with an example. Demonstrate
the use of [Link]() method for pattern matching.
2. Explain different types of inheritance in Python with examples.
3. Write a Python program that uses named groups in regular expressions to extract a
username and domain from an email address.
Section–C (11×3 = 33 Marks)
1. Define a class Employee with attributes name, salary, and a method show_details().
Inherit a subclass Manager that adds a department attribute and overrides the method to
display all details.
2. Write a Python program that takes a string containing multiple phone numbers and
uses regular expressions to extract all valid 10-digit numbers.
3. Develop a Python program that defines a class with both public and private methods.
Demonstrate accessing the private method through a public method.