OOP Using Python
OOP Using Python
Divgoku
Enrolment No: 28FEloCSE00D63
MANIPAL UNIVERSITY
JAIPUR
Odd Semester Mid Term Examination, Oct-2024
Faculty of Engineering, Schoolof Computer Science and Engineering
Department of Computer Science and Engineering
B. Tech -CSE
Course Code: CSE2122 Course: Object Oriented Programming using Python Semester: 3
Time: 1.5 hrs. Max. Marks: 30
Instructions: All questions are compulsory.
Missing data, if any, may be assumed suitably.
Calculator is not allowed.
SECTION A
S.No. Marks CO
QA1 What willbe the output of given code snippet?
string = 'FAITH
number='1947
i=0
X="
while i< len(string):
Co1
x=x+ string[i]+number[len(number) -i - 1]
i+=1
print(x)
(a.) FlA419T4H7 (c.) FAITH1947
(b.)F7A417T1H9 (d.) F7A419TIH7
returm count
d={'a':{b:{c:1}},;d:2}
print(doubleCool(d)
Write output of the code?
i=l
while i<=10:
if i%3!=0: COI
QA3
jt-2
elifj%3-0:
brcak
it=1
print(i+j)
SECTION B
Q
B1 Explain why tuples can be more efficient in terms of memory and performance compared
to lists. Provide a scenario where using tuple instead of alist would be beneficial. Analyze CO2
the differences between Python's collection types--Lists, Tuples, Sets, and Dictionaries.
Q
B2 Write a python program to construct the below pattern.
1
121
1232 1
12343 21 CO1
1232 1
121
4X 4=
16
QB3 (a.) What is a lambda function in Python, and how does it differ from a regular function?
Write a lambda function to filter out even numbers from a given list.
CO1
(b.)Differentiate iterator with recursion? Write a program to print the 1to 100 Fibonacci
series using recursive function?
Write a Python function named "count_consonants" that takes a string as input and
counts the number of consonants present in the string. The function should use a for loop
Q B4 to iterate over each character in the string and use an if statement to check if the character CO1
is aconsonant. The function should return the total count of consonant found.
SECTION-C
(a.) Give answers of the following:
1. Explain the uses of *args and **kwargs with syntax.
2. CreateaPython class named Circle constructed by a radius and two methods CO1
QCi which willcompute the area and the perimeter of a circle. 4X2=8 CO2
CO3
(b.) What are decorators? Analyze how decorators promote code reusability and
separation of concerns by evaluating a scenario where a logging decorator is applied to
multiple functions in an application.