Page 1 of 3 24F2-RU23-1L9L
Register No:……………………… Name:……………………………………
SECOND SEMESTER [Link] DEGREE (REGULAR) EXAMINATION, JUNE 2024
23ESB10H: PROGRAMMING USING PYTHON (CS, CT)
Duration: 2 Hours Max. Marks:40
Part A (Answer all questions)
1. Predict and justify the output for the following program: (2)
i=0
while i < 10:
i += 1
if i % 3 == 0:
continue
print(i)
2. Write a Python program to find the maximum of two numbers using lambda (2)
function.
3. Differentiate between dictionary and lists. (2)
4. Predict and justify the output for the following program. (2)
try:
result = 10 /2
except ValueError:
print("Error: Invalid input. Please enter a valid number.")
except ZeroDivisionError:
print("Error: Division by zero is not allowed.")
else:
print(f"The result is {result}")
5. Write a Python program that generates a 3x3 NumPy array filled with random (2)
integers in the range [1, 10]. Find and display the mean and maximum values for
the generated array.
Total (Part A) (10)
Part B (Answer any one full question from each module)
Module I
6. a) Write a Python program to print a number pattern where each row contains (3)
numbers from 1 to that row's number.
Example:
1
12
123
1234
b) Write a Python program that takes a student's marks for three subjects as input (3)
and calculates their total score and average marks. Based on the average marks,
print out their corresponding grade.
P.T.O.
Page 2 of 3 24F2-RU23-1L9L
7. a) Write a Python program using loop to check if a given number is palindrome or (4)
not.
b) Illustrate membership operators in Python using examples. (2)
Module II
8. Develop a menu-driven program to calculate the area of common shapes such as (6)
rectangle, square, circle, and triangle. Your program should provide users with a
menu to select the shape for which they want to calculate the area. Each shape
will have its own user-defined function to calculate the area
9. a) Write a Python program to implement binary search on a given list using (4)
recursion.
b) Predict and justify the output for the following code snippet: (2)
num_list = [y for y in range(100) if y % 2 == 0 if y % 5 == 0]
print(num_list)
Module III
10. Develop a menu-driven program for Bookstore Inventory Management. The (6)
system stores a list of books where each book in the inventory has the following
key values: title, author, price, and quantity available. Your program should
allow users to perform the following actions:
i. Add a new book to the inventory
ii. Update quantity available for a book
iii. Search for a book by title
11. a) Create a Python program that reads a text file ("[Link]") containing a list (3)
of numbers (one number per line). Sort the numbers in ascending order and write
them to another file ("sorted_numbers.txt").
b) Write a program to find the longest and shortest words in a string. (3)
Module IV
12. Implement a Python program using object-oriented programming to simulate a (6)
simple bank account management system. The program should provide
functionality for users to create a bank account, deposit money into the account,
withdraw money from the account, and display the current balance.
13. Illustrate exception handling in Python using short programs for the following (6)
exceptions:
a) FileNotFoundError
b) ValueError
c) IndexError
P.T.O.
Page 3 of 3 24F2-RU23-1L9L
Module V
14. a) Write a Python program that plots a simple line graph using Matplotlib. The (4)
x-axis should represent time (in seconds) from 0 to 10, and the y-axis should
represent the sum of terms in the range [0, x], where x varies from 0 to 10. Use
appropriate labels for the x-axis and y-axis.
b) Create a Python program that reads a CSV file containing student data and adds (2)
a new column to the dataframe representing the total marks obtained by each
student. Display the modified dataframe. A sample data is given below:
Name, Maths, Science, English
Alice, 85, 90, 88
Bob, 75, 82, 78
Charlie, 92, 88, 85
David, 80, 85, 90
Emma, 88, 78, 92
15. Write a Python program that creates a simple calculator using Tkinter. (6)
Total (Part B) (30)