Registration No: -
Total Number of Pages: 02 B.Tech / 19CS5ES01T
5th Semester Back Examination: 2024-25
PYTHON PROGRAMMING
BRANCH: CSE
Time: 3 Hours
Max Marks: 100
Q Code: S072
Answer Question No.1 (Part-1) which is compulsory, any EIGHT from Part-II and any TWO from
Part-III.
The figures in the right hand margin indicate marks.
Part-I
Q No. CO Level
Q1 Short Answer Type Questions (Answer All-10) (02x10)
a) 1 2 What are Python keywords and Identifiers? 2
b) 2 1 What is string slicing in Pytjhon? Give an example. 2
c) 2 1 What is the string formatting operator in Python? 2
d) 4 1 Define exception. 2
e) 2 1 What is class variable. Give example 2
f) 1 2 Show the difference between break and continue using example. 2
g) 2 2 What is __init__ 2
h) 2 2 What are python Membership operators? Show example. 2
i) 1 2 What are the data types available in Python? 2
j) 4 2 How do you do instantiate exceptions 2
Part-II
Q No. CO Level
Q2 Focused-Short Answer Type Questions- (Answer Any Eight out of Twelve) (06x08)
a) 1 2 What are Literals in Python? Explain Their Types with Examples. 6
b) 2 3 Write a Python Program Demonstrating the Usage of isupper(), find(), 6
count() and String Methods
c) 3 2 What are public and private data members in Python? Write a program to 6
create a class with both types of data members and demonstrate how to
access them within and outside the class.
d) 1 3 Write a Python function that takes a number as a parameter and checks the 6
number is prime or not
Page1
e) 2 3 How do you create a set and can get length and set items and the set() 6
constructor . Explain these with code.
f) 3 3 When a new object or instance of a class is created, which method is called 6
automatically? Illustrate with an example.
Page2
g) 3 2 Demonstrate with an example the four types of operations that Python can 6
perform on files: Open, Read, Write, and Close. Additionally, explain the
three methods available in Python to read files. Provide a comprehensive
example that includes all of these operations.
h) 2 3 Describe slicing in Python strings with suitable examples. Highlight the role 6
of step, start, and stop parameters. How is slicing applied to lists and
tuples?
i) 3 4 Write a Python class named Student with two attributes student_name, 6
marks. Modify the attribute values of the said class and print the original
and modified values of the said attributes
j) 3 2 What are abstract classes in Python? Write a program that defines an 6
abstract class with an abstract method, and implement this method in a
derived class to demonstrate its functionality.
k) 4 2 Explain the concept of exception handling in Python with an example 6
program. Demonstrate how to handle specific exceptions like
ZeroDivisionError and ValueError
l) 2 2 Differentiate between sets and dictionaries in Python with examples. 6
Explain how set operations like union, intersection, and difference work.
Part-III
Q No. CO Level
Long Answer Type Questions (Answer Any Two out of Four) (02x16)
Q3 a) 2 3 Write 2 separate programs to : 8
- Produce Fibonacci series in Python,
- Check if a given string is a Palindrome or not
b) 2 3 Write a Python program to demonstrate the following concepts: 8
Defining a class, Creating an object, Using constructors (both parameterized
and non-parameterized), Counting the number of objects created for a
class, Using getattr() and setattr() functions.
Q4 a) 1 4 Define a recursive function. Write a program to calculate the factorial of a 8
number using recursion. Explain how the function calls itself and the role of
the base case.
b) 1 4 What are lambda functions in Python? Write a Python program using a 8
lambda function to filter even numbers from a list and explain the working
of the lambda function.
Q5 a) 3 4 Write a program to explain the try expect statement in python. 8
Also With a code explain the try finally block in python.
b) 3 4 Write a Python program to show the use of multiple except blocks to 8
handle different types of exceptions. Explain how Python determines which
block to execute.
Q6 a) 3 3 Provide a detailed explanation of the two types of inheritance in Python— 8
multiple inheritance and multilevel inheritance—along with code examples:
b) 3 3 Write a Python program that demonstrates the use of the __init__() 8
constructor (both parameterized and non-parameterized) and the __del__()
Page3
destructor. Explain the scenarios where destructors are useful.