[Go to site: main page, start]

0% found this document useful (0 votes)
6 views4 pages

QB Module 4 and Module 5 Python

This document is a question bank for an Introduction to Python Programming course, covering various topics including namespaces, object mutability, inheritance, and exception handling. It contains two marks and four marks questions, as well as program-based questions for practical implementation. The questions aim to assess understanding of Python concepts and encourage coding practice through examples.

Uploaded by

sairan23
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

QB Module 4 and Module 5 Python

This document is a question bank for an Introduction to Python Programming course, covering various topics including namespaces, object mutability, inheritance, and exception handling. It contains two marks and four marks questions, as well as program-based questions for practical implementation. The questions aim to assess understanding of Python concepts and encourage coding practice through examples.

Uploaded by

sairan23
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Subject:Introduction to Python Programming

Code:25BPLC105A
Question Bank
Module-IV
Two Marks Questions:
1. Define a namespace in Python.
2. State the LEGB rule used for name lookup in Python.
3. List any two types of namespaces in Python.
4. Identify the operator used to access attributes of an object.
5. Give two examples of immutable data types in Python.
6. Name any two mutable objects in Python.
7. Recall the purpose of the self parameter in a class method.
8. Define aliasing with respect to Python objects.
9. State any two differences between mutable and immutable objects.
[Link] the three variants of the import statement in Python.
[Link] the special method used to convert an object into a string.
[Link] an object in Object-Oriented Programming.

Four Marks Questions:


1. Explain namespaces and scope in Python using a suitable example.
2. Illustrate the LEGB rule for name lookup with a Python program.
3. Explain attributes and the dot operator with an example program.
4. Compare mutable and immutable objects in Python with examples.
5. Demonstrate aliasing in mutable objects using a Python program.
6. Explain the three variants of the import statement with examples.
7. Describe the structure of a class and object in Python with an example.
8. Illustrate how attributes and methods are added to a class.
9. Explain how instances can be passed as arguments to functions with an
example.
[Link] how an instance is converted into a string using __str__()
method.
[Link] how a function can return an object (instance) in Python with
example.
[Link] between class attributes and instance attributes with suitable
examples.
Program Based Questions:
1. Develop a Python program to demonstrate namespaces and scope
using global, local, and enclosing variables. Explain the output.
2. Design and implement a Python program to illustrate mutable and
immutable objects along with aliasing. Analyze the results.
3. Write a Python program to create a class Student with attributes and
methods.
o Initialize data using constructor
o Display details using a method
o Convert the object to a string using __str__()
4. Construct a Python program to demonstrate all three import statement
variants using a standard library module.
5. Develop a Python program to show passing objects as arguments and
returning objects from functions.
6. Design a Python program to illustrate class attributes and instance
attributes clearly.
7. Write a Python program to demonstrate the use of dot operator for
accessing data members and methods of a class.
8. Develop a Python program to integrate the following concepts:
o Class and object creation
o Instance attributes and methods
o Passing object as parameter
o Returning object from function

Module-5

Two Marks Questions:


1. Define object mutability in Python.
2. State what is meant by sameness of objects.
3. Identify the operator used to test object sameness.
4. Differentiate between sameness (is) and equality (==).
5. List any two ways of copying objects in Python.
6. Define inheritance in Object Oriented Programming.
7. State the purpose of generalization in inheritance.
8. Identify what is meant by method overriding.
9. Define polymorphism in Python.
10. List any two advantages of inheritance.
11. Identify the special method used for operator overloading.
[Link] the module used for copying objects in Python.
[Link] a pure function.
[Link] any one characteristic of a pure function.
[Link] the purpose of access modifiers in OOP.
[Link] the three types of access modifiers supported in Python

[Link] an exception in Python.


[Link] the purpose of the try block.
[Link] the keyword used to catch exceptions.
[Link] the keyword used to raise a user-defined exception.
[Link] the base class for all exceptions in Python.
[Link] the role of the finally block

Four Marks Questions:


1. Write a Python program to demonstrate that objects are mutable using
a class object.
2. Develop a Python program to illustrate sameness and aliasing between
two object references.
3. Construct a Python program to show copying of objects using the copy()
method.

4. Write a Python program to demonstrate inheritance using base and


derived classes.
5. Develop a Python program to implement method overriding and show
polymorphism.
6. Construct a Python program to overload an operator using special
methods.

7. Write a Python program to catch a ZeroDivisionError using try–except.


8. Develop a Python program to raise a user-defined exception.

Program based Questions:


1. Design and implement a Python program to illustrate
o Object mutability
o Sameness (is) and equality (==)
o Copying objects
Explain the output.

2. Develop a Python program to demonstrate inheritance and


generalization using base and derived classes.
Show how derived classes reuse and extend base class behavior.
3. Construct a Python program to illustrate
o Method overriding
o Polymorphism using the same method name in different classes
4. Write a Python program to demonstrate operator overloading using
__add__() or __str__() method.

5. Design a Python program to demonstrate catching multiple exceptions


using try, except, and finally.
6. Develop a Python program to define and raise a user-defined
exception for invalid input and handle it appropriately.

You might also like