CONTINUOUS ASSESSMENT TEST – II
Regulations R2024 – V1.0
Department of Master of Computer Applications
First Year / First Semester
244MCC103T – Python Programming for Computational Applications
CO1: To develop Python programs with conditionals, loops and functions.
CO2: To use Python data structures – lists, tuples, dictionaries.
CO3: To do input/output with files in Python
CO4: To use modules, packages and frameworks in python
CO5: To define a class with attributes and methods in python
Unit – III FILE HANDLING AND EXCEPTION HANDLING
CO’s Bloom’s
Q.No Questions
Level
PART A
1. What do you mean by errors and exceptions? CO3 K1
2. How to view all the built-in exception in python. CO3 K1
3. Name two built-in exceptions in Python and describe their purpose. CO3 K2
4. What happens if an exception is not handled in Python? CO3 K2
5. Write an example of a NameError in Python. CO3 K2
6. How is the finally block used in exception handling? CO3 K2
7. What is the purpose of the else block in a try-except construct? CO3 K2
What is the output of the following code?
try:
8. print(10 / 0) CO3 K4
except ZeroDivisionError:
print("Division by zero.")
Can you have multiple except blocks for a single try block? Justify
9. CO3 K4
your answer.
10. Can the except block handle multiple exception types? If yes, how? CO3 K4
CO’s Bloom’s
Q.No Questions
Level
Part – B
Describe how exceptions are handled in python with necessary
1. CO3 K2
examples.
Write a Python program to handle the following exceptions:
ZeroDivisionError
2. FileNotFoundError CO3 K3
ValueError
Create a custom exception InvalidAgeError. Write a program that
3. CO3 K4
raises this exception if the user enters an age less than 18.
What is the use of the raise keyword in Python? Write a program to
4. CO3 K3
raise a ValueError if a user enters a non-integer value
Write a Python program to demonstrate nested try-except blocks, CO3
5. K3
explaining when each block will be executed
Write a Python program that opens a file and handles a CO3
6. K3
UnicodeDecodeError exception if there is an encoding issue.
CO’s Bloom’s
Q.No Questions
Level
Part C
Demonstrate the exception handling with the difference between the
1. CO3 K5
else block and finally block with an example program.
Write a function called sed that takes as arguments a pattern string, a
replacement string, and two filenames; it should read the first file
and write the contents into the second file (creating it if necessary). If
2. the pattern string appears anywhere in the file, it should be replaced CO3 K5
with the replacement string. If an error occurs while opening,
reading, writing or closing files, your program should catch the
exception, print an error message, and exit.
Unit – IV MODULES, PACKAGES AND FRAMEWORKS
CO’s Bloom’s
Q.No Questions
Level
Part A
1. What is a Python module? Give an example. CO4 K2
2. How do you import a module in Python? Write a code snippet. CO4 K1
3. What is the difference between a module and a package in Python? CO4 K2
How can you check the list of functions or attributes of a module in CO4
4. K1
Python?
5. What is the purpose of the __init__.py file in a package? CO4 K2
6. What steps are required to create a custom module in Python? CO4 K2
How do you execute a function from a custom module after CO4
7. K1
importing it?
8. What is the primary use of the NumPy library? CO4 K2
9. Write a Python statement to create a 2D array using NumPy. CO4 K1
10. How is a Pandas DataFrame different from a NumPy array? CO4 K2
11. What is the function of the read_csv() method in Pandas? CO4 K2
Write a Python code snippet to plot a simple line graph using CO4
12. K3
Matplotlib.
13. What is the use of the pivot_table() method in Pandas? CO4 K2
How is the from module import * syntax different from import CO4
14. K1
module?
15. What steps are required to create a custom module in Python? CO4 K2
16. What is a Python framework? Give two examples. CO4 K2
17. Differentiate between Django and Flask. CO4 K2
18. What is the difference between a library and a framework? CO4 K2
19. What is the purpose of virtual environments in Python? CO4 K2
Name two Python libraries for machine learning other than NumPy CO4 K1
20.
and Pandas.
CO’s Bloom’s
Q.No Questions
Level
Part b
What are the modules in python? How will you import them? CO4
1. K3
Explain the concept by creating and importing a module?
What are Python packages? Discuss the structure of a package and CO4
2. the role of the __init__.py file. Write an example of creating and K3
using a package.
Differentiate between a module, a library, and a package in Python. CO4
3. K3
Illustrate with examples of each.
4. Explain Matplotlib library with example. CO4 K3
5. Compare and contrast Django and Flask as web frameworks CO4 K4
6. Discuss the NumPy library in Python in detail CO4 K2
7. Explain the Pandas library with examples CO4 K2
CO’s Bloom’s
Q.No Questions
Level
Part- C
Write a Python program to create a custom module that contains
functions for:
Calculating the factorial of a number.
1. CO4 K3
Finding the greatest common divisor (GCD) of two numbers.
Demonstrate how to import and use these functions in
another Python script.
What is the difference between Matplotlib and Plotly? Write
programs to create:
2. CO4 K3
A simple line plot using Matplotlib.
An interactive bar chart using Plotly.
Unit – V OBJECT ORIENTED PROGRAMMING IN PYTHON
CO’s Bloom’s
Q.No Questions
Level
Part A
1. What is a class in Python? CO5 K2
2. What is the purpose of the __init__ method in a class? CO5 K2
What is a class method in Python? How does it differ from an CO5 K2
3.
instance method?
4. What is the purpose of the cls parameter in a class method? CO5 K2
What is the difference between single inheritance and multiple CO5
5. K2
inheritance in Python?
6. What is method overriding in Python? Provide an example. CO5 K2
7. Can a subclass call the method of the parent class? How? CO5 K1
8. How do you access private variables in Python? CO5 K1
9. Explain how encapsulation helps in data hiding in Python. CO5 K1
What is method overloading? Does Python support method CO5
10. K2
overloading?
11. How does polymorphism benefit object-oriented design in Python? CO5 K1
What is the difference between a class method and a static method in CO5
12. K2
Python?
13. How do you define a static method in Python? CO5 K1
What is method overloading? Does Python support method CO5
14. K2
overloading?
15. How does polymorphism benefit object-oriented design in Python? CO5 K1
16. What is the @staticmethod decorator used for in Python? CO5 K2
17. When would you use a class method over a static method? CO5 K2
18. What is object persistence in Python? Why is it useful? CO5 K2
19. Which Python module is commonly used for object persistence? CO5 K1
How would you save an object to a file and retrieve it later in CO5
20. K1
Python?
CO’s Bloom’s
Q.No Questions
Level
Part – B
Implement encapsulation in Python by creating a class Student with
1. private attributes for name, roll_number, and marks. Provide getter CO5 K3
and setter methods for accessing and updating these attributes.
Differentiate between instance methods, class methods, and static
2. CO5 K4
methods in Python. Provide examples to support your explanation.
Define a class Vehicle with attributes make, model, and year. Create
two subclasses: Car and Bike, each adding a specific method (e.g.,
3. CO5 K3
car_info and bike_info). Implement method overriding to display
information specific to Car and Bike in the overridden method.
Write a Python program to demonstrate multiple inheritance. Define
two classes Person (with attributes name, age) and Employee (with
4. CO5 K3
attribute salary). Create a subclass Manager that inherits from both
Person and Employee, and display the manager's details.
What is abstraction in Python? Write a Python program that CO5
demonstrates abstraction by creating an abstract class Shape with an
5. K3
abstract method draw(). Implement two concrete classes Circle and
Square that override the draw() method.
Write a Python program to demonstrate operator overloading. Create
6. a class ComplexNumber and overload the + operator to add two CO5 K3
complex numbers.
Explain the concept of object persistence in Python using the pickle
module. Write a Python program to serialize and deserialize a
7. CO5 K3
Student object (with attributes name, roll_number, marks) to and
from a file.
Demonstrate the use of super() in Python. Write a Python program
8. with a base class Animal and a subclass Dog that calls the CO5 K4
constructor of the base class using super().
CO’s Bloom’s
Q.No Questions
Level
Part C
Write a Python program to implement inheritance and method
1. overriding. Create a base class Shape and derived classes Rectangle CO5 K3
and Circle to calculate their area and perimeter.
Write a Python program demonstrating polymorphism. Create a Bird
2. class and a Penguin class where both have a method move(), but they CO5 K3
perform different actions.