0% found this document useful (0 votes)
6 views

Practical ans key

The document outlines a practical exam for 2025, consisting of multiple papers with programming tasks in Python and SQL. It includes functions for managing cricket player statistics, book records, employee data, and inventory items, as well as database table creation and manipulation commands. Each section contains code snippets for specific functionalities, such as adding records, calculating averages, and displaying data based on user input.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Practical ans key

The document outlines a practical exam for 2025, consisting of multiple papers with programming tasks in Python and SQL. It includes functions for managing cricket player statistics, book records, employee data, and inventory items, as well as database table creation and manipulation commands. Each section contains code snippets for specific functionalities, such as adding records, calculating averages, and displaying data based on user input.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Model PRACTICAL EXAM-2025

Paper-1

Section-A

1.

import csv

def add():

f = open (cricket.csv”, “w”, newline = “”)

mywriter = csv. writer (f, delimiter=’,’)

mywriter. writerow ([‘Playername,‘Runs scored’, ‘Matches played ‘])

while True:

name = input(“Enter the player name”)

runs = int (input (“enter the runs scored”))

match = int (input( “enter the no. of matches”))

l= [name, runs, match]

mywriter. writerow (l)

ch= input (“Do you want to continue ? Y/N”)

if ch. upper() != ‘Y”:

break

f. close()

def averageruns():

f = open(‘cricket .csv”, “r”, newline = ‘’)

myreader = csv. reader (f, delimiter = “;”)

next (myreader)

for r in myreader:

avg = int(r[1])/ int (r[2])

print (“Name:’r[0], “Total Runs:”,r [1],“Matches:”,r [2],


“Average:”,avg)
f. close()

# Main

print(‘’’ Menu

1.Add details.

2.Display average’’’)

n=int (input (“enter your choice”))

if n==1:

add()

if n==2:

averageruns()

else:

pass

2.

1.create table Issues (Book_ ID char(3) primary Key, Qty_Issued int );

Insert into issues

Values (‘L02’,13),

(‘L04’ ,5);

Similarly, other records are inserted

Create table Books (Book_ID char (3) references Issues (Book_ID),

BookName varchar(20) NOT NULL, AuthorName varchar (30),

Publisher char (3),Price int, Qty int);

Insert into Books

Values (‘L01’, ‘Maths”, “Raman”, “ABC” 70,20);

Similarly, other records are inserted


(ii) Select Bookname, Authorname, Price from Books where publisher =
“ABC”;

(iii) Select * from Books natural join Issues;

(iv)delete from Books where price > 85;

Paper-2

Section-A

1.

import pickle as p

def addbooks():

with open (“books. Dat”, “ab” ) as f:

B_name = input(“enter the book name?”)

Author = input(“enter the author “)

Price = float Cinput Center the price

l=[B_name, Author, Price]

p.dump (l,f)

def displayprice():

f = open(“books.dat”, “rb”)

while True:

try:

e=p.load(f)

if e[2]> 300:

print(e)

except EOFError:

break

f.close()
#main

print ( ‘’’Menu

1. Add books
2. Display
3. Exit ‘’’)

ch=int (input(“enter your choice”))

if ch == 1:

n=int (input(“enter the no. of records “))

for i in range(n):

addbooks()

elif ch = = 2:

displayprice()

else:

pass

2.

(i)create table Employee (No int primary Key,Name varchar(30),Salary


int,Zone varchar(10),

Age char(2),Grade char (2),Dept char (2));

Insert into Employee

Values (1, ‘Mukul’, 30000, ‘West “$ 28, ‘A’, 10),

(2, ‘Krithika, 35000, ‘Centre”, 30, ‘A’, 10);

Similarly other records are inserted

(ii) Select * from employee order by salary:

(iii)Select zone, count (zone) from employee group by zone;

(iv)Select grade, max (salary) from employee group by grade;

Paper-3
Section-A

1.

Stk = []

def push_cities (city):

for i in city:

if city [i]>35:

Stk. Append (i)

def pop():

while Stk:

print (Stk. Pop())

else:

print (“Stack underflow”)

#main

While True:

print(‘’’Menu

1.push cities

2.pop and display

3.exit’’’)

ch=int (input (“enter your choice”))

if ch ==1:

city = {“Chennai”: 40, “Bengaluru”: 34,” Trichy” : 41,


“Madurai”: 44, “Ooty”: 2}

push_cities (city)

elif ch ==2

pop()

else:
break

Section-B

2.

i. Create table Items (ID char (4) primary Key, PName varchar (20),Price
float,MDATE date, Qty int );

Insert into Items

Values (‘T001’, ‘Soap’, 12.00, ‘2007-03-11’,200);

Similarly, other records are inserted

(ii)Select Pname, Price*Qty from Items where Mdate between 2007-01-01’


and ‘2007-12-31; or

Select Pname, Price*Qty from Items where year(Mdate)=2007

(ⅲ)Update items set Qty = Qty + 20 where pname in (‘soap’, ‘paste ‘);

(iv)delete from items where price between 10 and 30;

Paper-4

Section-A
1.

def countlines ():

f = open (“notes.txt””, “r”)

c=0

for i in f:

If i[0]. Upper()= = ‘S’:

c+=1

print (“no. of lines starting with s”, c)

f. close()

def Displayfour():

f = open(“notes.txt”,”r”)

s= f. read()

l= s. split()

for i in l:

if len (i) = = 4:

print (i)

f. close

#main

While True:

print (‘’’Menu

1. Count the lines.

2.Four letter words

3.exit’’’)

ch=int(input(“enter ur choice”))

if ch==1:
countlines()

if ch==2:

Displaylines()

else:

break

Section-B

2.

1.Create table Items (ID char (4) primary Key, PName varchar (20),Price
float,MDATE date, Qty int );

Insert into Items

Values (‘T001’, ‘Soap’, 12.00, ‘2007-03-11’,200);

Similarly, other records are inserted

Create table Company( ID char(4) references Items(ID), Comp varchar(20),


City varchar(20));

Insert into Company

Values(‘T001’,’HLL’, ‘Mumbai’);

Similarly, other reacords are inserted

(ii) delete from items where year(Mdate)<2007;

(iii) select Pname, Comp from Items I , Company C where I.ID=C.ID where
name like ‘A%’;

(iv) select city, count(city) from Company group by city;

Paper-5
Section-A

1.

Expensive= []

def push(product):

for i in product:

if product [i]>10000:

Expensive. Append (i)

def pop():

if Expensive:

print (Expensive. Pop())

else:

print (“Stack underflow”)

def display():

if Expensive:

for i in Expensive[::-1]:

print(i)

else:

print(“Stack underflow”)

#Main

While True:

Print(‘’’Menu

1.push

2.diplay

3.Pop

4. Exit’’’)

ch=int (input (“enter your choice”))


if ch ==1:

product={“Speaker”:1000,”Laptop”:30000,”Ac”:35000,”Monitor”:9000}

push(product)

elif ch ==2

display()

elif ch==3:

pop()

else:

break

2.

a)

Create table Hospital( ID int primary key, Name varchar(20), Age char(2),
Department varchar(30), Charges int , Gender char(1));

Insert into hosital

Values(1, ‘Arprit’,62,’Surgery’, 300, ‘M’);

Similary other records are inserted

b) select * from hosital where department=”Gynecology”;

c) select Name from hospital where gender=’F’ and department=’ENT’;

d) select name , gender from hospital where age between 40 and 70 order
by name;

Paper-6

Section-A

1.

def countwords ():


f= open (“notes.txt””, “r”)

cshe=che=0

s=f.read()

l=s.split()

for i in l:

if i.upper()==’HE’:

che+=1

elif i.upper()==’SHE’:

cshe+=1

print (“no. of she’s:’ cshe)

print(“no. of he’s:”che)

f. close()

def Displaylines():

f = open(“notes.txt”,”r”

l= f.readlines()

for i in l:

if i[0].lower() in “aeiou”:

print (i)

f. close

#main

while True:

Print (‘’’Menu

1. Count the words he and she

2.display lines
3.exit’’’)

ch=int(input(“enter ur choice”))

if ch==1:

Countwords()

if ch==2:

Displaylines()

else:

Break

2.

i.

Create table Items (ID char (4) primary Key, PName varchar (20),Price
float,MDATE date, Qty int );

Insert into Items

Values (‘T001’, ‘Soap’, 12.00, ‘2007-03-11’,200);

Similarly, other records are inserted

(ii)Select Pname, Price*Qty from Items where Mdate between 2007-01-01’


and ‘2007-12-31; or

Select Pname, Price*Qty from Items where year(Mdate)=2007

(ⅲ)Update items set Qty = Qty + 20 where pname in (‘soap’, ‘paste ‘);

(iv)delete from items where price between 10 and 30;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy