CSE2025 – PYTHON PROGRAMMING
End Term Examination – Sample Paper
Max Marks: 40 Duration: 2 Hours
Instructions:
- All questions are compulsory.
- Assume any missing data if necessary.
- Use of calculator (non-scientific) is allowed.
Section A – Logic and Application-Based Questions (32 Marks)
1. Write a Python program that takes a list of integers and returns a new list containing
only the prime numbers from the original list.
(Hint: Implement a function to check if a number is prime.) [4 Marks]
2. Create a Python program that takes a sentence from the user and prints the frequency of
each word in the sentence.
(Use a dictionary for word counts.) [4 Marks]
3. Write a Python function that takes a dictionary where keys are product names and
values are their prices. The function should return the product with the maximum price.
[4 Marks]
4. Write a Python program that reads a file named `data.txt` and counts the number of
lines, words, and characters in the file.
(Assume the file exists and is accessible.) [4 Marks]
5. Define a class `Student` with attributes `name`, `marks` (dictionary of subjects and
marks), and methods to calculate total marks and percentage. Demonstrate usage with a
sample object. [4 Marks]
6. Write a Python program that:
- Generates random marks (0–100) for 5 students in 3 subjects using NumPy.
- Stores them in a Pandas DataFrame.
- Adds a column for the average marks of each student.
- Plots a bar chart of average marks using Matplotlib. [6 Marks]
7. Write a Python function using exception handling to perform division of two numbers. It
should handle the following:
- Division by zero
- Invalid input (non-numeric) [6 Marks]
Section B – Conceptual Questions (8 Marks)
8. Differentiate between mutable and immutable data types in Python with suitable
examples. [2 Marks]
9. Explain the concept of lambda functions. Provide an example where it is used with
`map()`. [2 Marks]
10. What is the significance of the `__init__()` method in Python classes? [2 Marks]
11. List any four differences between lists and tuples. [2 Marks]