Ssce MS
Ssce MS
QUESTIONS MARKS
1. Python Program 08
i)Write a program to read the content of file & to display each word separated by '#'
f=open("D:\\story.txt",'r')
a=f.read()
b=a.split()
for i in b:
print(i,end="#")
f.close()
count=0
for i in string.lower():
if i in 'aeiou':
count+=1
OR
ii)Write a Python Program to Create a binary file with Empno, Name, Salary
then read and display their details on screen.
import pickle
def write():
f=open("d:\\employee.dat", 'wb')
while True:
data=[emp,name,slry]
pickle.dump(data,f)
if ch=='n' or ch=='N':
break
f.close()
def read():
fi=open("d:\\employee.dat",'rb')
try:
print("file contents")
while True:
x=pickle.load(fi)
print(x)
except:
fi.close()
write()
read()
TABLE : STUDENT
b) To list the names of all students with their Date of joining in ascending order.
c) To list the name and department of all students whose name starts with ‘S’
count(distinct department)
3. REPORT FILE 07
4. PROJECT 08
5. VIVA 03
TOTAL 30
SSCE PRACTICAL EXAMINATION (2024 - 2025)
COMPUTER SCIENCE - NEW (083)
STD : XII SET B SCHOOL CODE: 55406
MAX. MARKS : 30 DURATION: 3 hrs
QUESTIONS MARKS
1. Python Program 08
i) Write a program to read a text file & display the number of vowels/
f=open("d:\story.txt", 'r')
line=f.read()
print(line)
v=0
c=0
l=0
u=0
for i in line:
if i in 'aeiouAEIOU':
v+=1
if i in 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ':
c+=1
if i.islower():
l+=1
if i.isupper():
u+=1
OR
i) Write a Python program that implements a stack using a list. The stack
should only contain integers that are divisible by 3 but not divisible by 6.
Your program should include the following user-defined functions:
pop(): Removes the top element from the stack. If the stack is empty, the
function should return a message indicating that the stack is empty.
S=[]
def push(x):
for i in x:
S.append(i)
def display():
def pop(b):
if S!=[]:
else:
print('STACK IS EMPTY')
push(l)
display()
pop(S)
Book_ID Quantity_issued
T001 4
C001 5
F001 2
TABLE: ISSUED
a) To display the Book_ID,Book_Name and Quantity_issued for all books which have
been issued.(The query will require contents from both the tables)
count(distinct Publishers)
max(Price)
750
3.REPORT FILE 07
4.PROJECT 08
5.VIVA 03
TOTAL 30
QUESTIONS MARKS
1. Python Program: 08
Write a Python program Create a CSV file to store Rollno, Name, Age
and search any Rollno and display Name, Age and if not found display
appropriate message
import csv
def write():
fobj=csv.writer(f)
for i in range(n):
name=input("enter name:")
age=int(input("enter age:"))
data=[rno, name, age]
fobj.writerow(data)
f.close()
def search():
s=0
fobj=csv.reader(fi)
for i in fobj:
if i[0].isdigit():
if int(i[0])==rno:
print(i[1],i[2])
s=1
break
if s==0:
fi.close()
write()
search()
Table : WORKER
a) To count and display MALE workers who have joined after ‘1986-01-01’.
count(*) >1;
count(*) DCODE
2 D01
max(DOJ) Min(DOB)
2014-01-17 1984-10-19
3.REPORT FILE 07
4.PROJECT 08
5.VIVA 03
TOTAL 30
SSCE PRACTICAL EXAMINATION (2024 - 2025)
COMPUTER SCIENCE - NEW (083)
STD : XII SET D SCHOOL CODE: 55406
MAX. MARKS : 30 DURATION: 3 hrs
QUESTIONS MARKS
1. Python Program 08
Python program to create a binary file with roll number, name and marks. Input a
roll number and update the marks
import pickle
def write():
f = open("d:\\record.dat", 'wb')
l = []
while True:
l.append(data)
if ch == 'n' or ch == 'N':
break
pickle.dump(l, f)
f.close()
def update():
fi = open("d:\\record.dat", 'rb+')
try:
x = pickle.load(fi)
s=0
for i in x:
if i[0] == roll:
s=1
break
if s == 0:
else:
fi.seek(0)
pickle.dump(x, fi)
except:
fi.close()
write()
update()
Table: School
Code TeacherName Subject DOJ Periods Experience
TEACHER;
TEACHER
Umesh
Yashraj
COUNT(*) GENDER
5 MALE
2 FEMALE
3.REPORT FILE 07
4.PROJECT 08
5.VIVA 03
TOTAL 30
SSCE PRACTICAL EXAMINATION (2024 - 2025)
COMPUTER SCIENCE - NEW (083)
STD : XII SET E SCHOOL CODE: 55406
MAX. MARKS : 30 DURATION: 3 hrs
QUESTIONS MARKS
1. Python Program 08
Write a Python program Create a CSV file to store bookid, bookname, price and count
and display the number of books where the price is more than 1000.
import csv
def writecsv():
f=open("d:\\books.csv",'w',newline='')
fobj=csv.writer(f)
fobj.writerow(['BOOKID','BNAME','AUTHORNAME','PRICE'])
rec=[]
data=[b_id,bname,a_name,price]
rec.append(data)
fobj.writerows(rec)
def countcsv():
f=open("d:\\books.csv",'r',newline='')
c=0
fobj=csv.reader (f)
x=list(fobj)
for i in x:
if i [3].isdigit():
if int(i[3])>1000:
c+=1
f.close()
writecsv()
countcsv()
OR
Write a Python Program to Create a binary file with Empno, Name, Salary then read and
display their details on screen
import pickle
def write():
f=open("d:\\employee.dat", 'wb')
while True:
data=[emp,name,slry]
pickle.dump(data,f)
if ch=='n' or ch=='N':
break
f.close()
def read():
fi=open("d:\\employee.dat",'rb')
try:
print("file contents")
while True:
x=pickle.load(fi)
print(x)
except:
fi.close()
write()
read()
Table : COMPANY
AVG(QTY)
7.5
e) SELECT PRODUCTNAME,CITY, PRICE
FROM COMPANY, CUSTOMER WHERE
COMPANY. CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;
3.REPORT FILE 07
4.PROJECT 08
5.VIVA 03
TOTAL 30
1. Python Program 08
Write a Python program Create a CSV file to store Rollno, Name, Age and search any
Rollno and display Name, Age and if not found display appropriate message.
import csv
def write():
fobj=csv.writer(f)
for i in range(n):
name=input("enter name:")
age=int(input("enter age:"))
fobj.writerow(data)
f.close()
def search():
s=0
fobj=csv.reader(fi)
for i in fobj:
if i[0].isdigit():
if int(i[0])==rno:
print(i[1],i[2])
s=1
break
if s==0:
fi.close()
write()
search()
Table : COMPANY
AVG(QTY)
7.5
3.REPORT FILE 07
4.PROJECT 08
5.VIVA 03
TOTAL 30
SSCE PRACTICAL EXAMINATION (2024 - 2025)
COMPUTER SCIENCE - NEW (083)
STD : XII SET G SCHOOL CODE: 55406
MAX. MARKS : 30 DURATION: 3 hrs
QUESTIONS MARKS
1. Python Program 08
Write a program that implements a stack using a dictionary to store stationery items and
their prices. The stack should only contain stationery items whose price is greater
than100. Your program should include the following user-defined functions:
1. push(): Adds a stationery item name to the stack if the price is greater than 100.
2. peek(): Displays the name of the top item in the stack without removing it. If the
stack is empty, the function should return a message indicating that the stack is
empty.
3. pop(): Removes and displays item from the stack. If the stack is empty, the
function should return a message indicating that the stack is empty
dict1={'pen':50,'notebook':120,'markers':200,'pencil':20,'paint':240,'glue':90}
stack=[]
def push(a):
for i in a:
if a[i]>100:
stack.append(i)
return stack
def peek(x):
if stack!=[]:
else:
print("stack empty")
def pop(y):
for i in range(len(stack)+1):
if stack!=[]:
else:
print(push(dict1))
peek(stack)
pop(stack)
COUNT(distinct dept)
4
e) Select MAX(age) from student where Gender=’F’.
MAX(age)
21
3.REPORT FILE 07
4.PROJECT 08
5.VIVA 03
TOTAL 30
1. Python Program
Ishita, an IT consultant, has a binary file products.dat containing product details. She
needs to write a user-defined function Filter_items() to create a new binary file
available_products.dat, which includes all product details except the product with
item_id 404. The data in the binary file is stored as: {item_id: [product_name,
quantity_available]}. Guide her in completing this task with the appropriate Python
code. 08
import pickle
def Filter_items():
d={}
f=open("d:\\products.dat",'rb')
f1=open("d:\\available_products.dat", 'wb')
try:
product = pickle.load(f)
for i in product:
if i!=404:
d[i]=product[i]
pickle.dump(d,f1)
except EOFError:
f.close()
f1.close()
Filter_items()
04
Distinct Address
DELHI
CHENNAI
BANGALORE
MUMBAI
CAMLIN 30 20 2
DOMS 5 5 2
3.REPORT FILE 07
4.PROJECT 08
5.VIVA 03
TOTAL 30