COURSE CODE : INT213
COURSE NAME : PYTHON PROGRAMMING
Read the following instructions carefully before attempting the question paper.
- This question paper is divided into two parts A and B.
- Part A contains 10 questions of 2 marks each. All questions are compulsory.
- Part B contains 5 questions of 10 marks each. In each question attempt either question (a) or (b), in case both (a) and (b) questions are attempted for any question then only the first attempted question will be evaluated.
- Answer all questions in serial order.
- Do not write or mark anything on the question paper except your registration no. on the designated space.
PART A
-
Q1 a) Explain the difference between deep copy and shallow copy in Python with respect to mutable objects. [ 2 Marks ]b) What are Python decorators? Write a basic syntax outline for creating a function decorator. [ 2 Marks ]c) Differentiate between __init__ and __new__ methods in Python class execution lifecycle. [ 2 Marks ]d) Predict the exact console output for the following structural python code block: [ 2 Marks ]my_list = [x for x in range(5) if x % 2 == 0] print(list(map(lambda x: x ** 2, my_list)))e) What is the dynamic behavior and output of the following statement: print(type({x for x in ‘python’})) [ 2 Marks ]f) Explain how context managers handle exception handling inside a standard with block structure. [ 2 Marks ]g) Define method resolution order (MRO). How does Python evaluate hierarchy structures under multiple inheritance? [ 2 Marks ]h) Explain the core computational functional variations between Python Generators and traditional Iterators. [ 2 Marks ]i) What are list comprehensions? Convert a basic nested loop append criteria matrix into a single line format. [ 2 Marks ]j) Distinguish between the operational utilities of args and kwargs variables inside a parameters function definition. [ 2 Marks ]
PART B
-
Q2 a) Write a Python program to find and print all prime numbers between two user-defined intervals using an optimized algorithm (e.g., Sieve of Eratosthenes). [ 10 Marks ]ORb) (i) Explain the concept of Exception Handling in Python using try, except, else, and finally blocks with a clear code layout. [ 5 Marks ](ii) What is a Lambda function? Write a python program that uses filter() and map() functions with lambda to extract and square even numbers from a list. [ 5 Marks ]
-
Q3 a) (i) Write a recursive Python function to compute the nth Fibonacci number and explain its time complexity.(ii) Modify the above recursive logic into an optimized dynamic programming version using memoization to reduce runtime. [ 10 Marks ]ORb) (i) Write a comprehensive program to handle file input/output operations, demonstrating how to handle file-not-found errors cleanly. [ 5 Marks ](ii) Discuss variable scoping in Python (Local, Global, and Nonlocal) with the help of suitable multi-nested function examples. [ 5 Marks ]
-
Q4 a) Write a Python program to read a text file, count the occurrences of each unique word inside it, and save the word frequencies into a separate structured dictionary log. [ 10 Marks ]ORb) (i) Create a class hierarchy demonstrating encapsulation and polymorphism where a base class ‘Vehicle’ is inherited by ‘Car’ and ‘Bike’ subclasses. [ 5 Marks ](ii) What are abstract classes in Python? Write a python script using the ‘abc’ module to implement an abstract base interface. [ 5 Marks ]
-
Q5 a) Write a script to demonstrate regular expressions (re module) by parsing a bulk text block to extract valid Email IDs, Phone numbers, and URLs. [ 10 Marks ]ORb) (i) Write a python program using a database connector (SQLite3/MySQL) to perform basic CRUD operations (Insert, Read, Update, Delete) on a ‘Products’ table. [ 5 Marks ](ii) What are list comprehensions and generator expressions? Compare their memory efficiencies with practical verification. [ 5 Marks ]
-
Q6 a) Write a NumPy program to perform matrix multiplication, find the transpose, and calculate the determinant of a user-defined multi-dimensional array matrix. [ 10 Marks ]ORb) (i) Explain how the Pandas library can be used to handle missing data values (NaN) inside a structural dataframe file. [ 5 Marks ](ii) Write a python program using Matplotlib to plot a clean line graph and bar chart showing sales performance metrics over a given period. [ 5 Marks ]
— End of Question Paper —