Friday, 7 November 2025

Sample practical paper II

 SECTION A


1. Write a menu driven program to operate on a csv file courier.csv with each record as a list of the

form :

[courier_id, name, city, fees].

The menu should

a) Insert records into the file.

b) Display records, the total of the fees and the average fees

c) Search and display the details of a given courier_id

2. Your Principal has chosen you to to help maintain the records of grade 12 students in a stack format.

Each record should contain { ‘s_id’:int, ‘s_name’:str , ‘s_marks’: int}

You decide to implement stack data structure to maintain the records of your classmates to perform the

following operations on the stack , in a menu driven fashion

i) Push

ii) Pop

iii) Display (at the end of the display , print the average marks of the students, and the topper’s details)


SECTION B


3.Consider the following table:

Write SQL Queries to create the above tables and insert records into them, and write queries for

the following:

a) To display employee ids, names of employees, job ids with corresponding job titles. 

b) To display names of employees, sales and job titles who have achieved sales more than 1300000.

c) To display names who have ‘SINGH’ (anywhere) in their names.

d) Write SQL command to change the jobid to 104 of the employee with ID as E4 in the table

Employee.

e) Display a list of jobid, job name and number of employees

f) Display only the jobs with salary greater than or equal to the average salary.

g) Increase “manager” salary by 5 percent.

Sample practical paper - I

 SECTION A


1. Write a menu-driven program to operate on a binary file book.dat with each record stored as a list in

the form:

[book_id (int), book_title (string), price (int)].

The menu should perform the following operations:

a) Insert records into the file.

b) Display all records, the total cost of all books, and the average price of books.

c) Update the price of a given book_id, else display a suitable message.


2. You are an excellent coder. So your neighbour Amit, who owns a departmental store tells you to help

him maintain the records of a customer’s cart in a stack format.

You decide to implement stack data structure to maintain the records of the shopping cart to perform the

following operations on the stack the, in a menu driven fashion

i) Push

ii) Pop

iii) Display (at the end of the display , print the total price of the cart)

Note : Each record is of the structure :

{‘p_id’: int , ‘p_name’ :str , ‘price’: float}.


SECTION B


3. Create the below tables and write the SQL statements for the queries that follow :


1. Display the names of borrowers who borrowed a book in December 2024.

2. List the book titles borrowed by borrowers living in Mumbai.

3. Find the total number of books borrowed by each borrower( id and name).

4. Display the city-wise count of books borrowed in descending order of count.

5. List the names of borrowers who have not returned at least one book

6. Display the borrowers who have returned all the books .

7. Update return date of Kavya Iyer’s unreturned books to 2025-09-09.


Thursday, 6 November 2025

Binary files practice

 Write a Python functions :

STUDENT_ADD() that adds new students to the file student.dat. 

Each record in the file contains the following information for a student:

  • Roll Number (integer)

  • Name (string)

  • sPercentage (float)

STUDENT_UPDATE() that changes the percentage of a certain roll number.

>Display if student not found



Monday, 3 November 2025

CSV file practice


(a) Write one point of difference between seek() and tell() functions in file handling. Write a program in Python that defines and calls the following user defined functions :

(i) Add_Device() : The function accepts and adds records of the peripheral devices to a csv file ‘peripheral.csv’. Each record consists of a list with field elements as P_id, P_name and Price to store peripheral device ID, device name, and price respectively.

(ii) Count_Device() : To count and display number of peripheral devices, whose price is less than ₹1000.

                                                   

(b) Write a program in Python that defines and calls the following user defined functions :

(i) Add_Teacher() : It accepts the values from the user and inserts record of a teacher to a csv file “Teacher.csv”. Each record consists of a list with field elements as T_id, Tname and desig to store teacher ID, teacher name and designation respectively.

(ii) Search_Teacher() : To display the records of all the PGT (designation) teachers.


Sunday, 2 November 2025

Text file practice

''' Write a function in Python that copies the book names having ‘Y’ or ‘y’ in

their name from a text file

“Bookname.txt” into another file Yy.txt Finally display Yy.txt and the total

number of Books in the text..

Example:

If the file ‘Bookname.txt’ contains the names of following books :

One Hundred Years of Solitude

The Diary of a Young Girl

On the Road

After execution, the output will be :

One Hundred Years of Solitude

The Diary of a Young Girl

No of Books in Yy.txt : 2'''


def func():

    l=[]

    with open('bookname.txt','r') as f:

        text=f.read()

        lines=text.splitlines()

        for i in lines:

            if 'y' in i or 'Y' in i:

                l.append(i)


    with open('yy.txt','w') as f:

        f.writelines(l)


    with open('yy.txt','r') as f:

        text=f.read()

        lines=text.splitlines()

        print(text)

        print('no of books : ',len(lines))



'''

Write a function RevString() to read a textfile “Input.txt” and prints the words starting with

‘O’ in reverse order. The rest of the content is displayed normally.


Example:

If content in the text file is :

UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM



Output will be :

UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM

(words ‘OPEN’ and ‘OPERATING’ are displayed in reverse order)

'''       

with open('input.txt','r') as f:

        text=f.read()

        s=''

        words=text.split()

        for i in words:

            if i[0].lower()=='o':

                s=s+i[::-]+' ')

            else:

                s=s+i

print(s)