2025-2026
COMPUTER SCIENCE LAB MANUEL
CLASS : 12
PREPARED BY : ARCHNA
KAUSHIK FOR COMPUTER
DEPARTMENT, KGDSSVM
RAJNAGAR
Page 0
INDEX
1. MARKING SCHEME- LAB
2. RECORD PROGRAMS LIST– PYTHON
3. PYTHON RECORD PROGRAMS
4. SQL QUERIES FOR RECORD
5. PRACTICE PROGRAMS– PYTHON
6. SQL QUERIES FOR PRACTICE
7. SAMPLE PRACTICAL PAPER.
8. SAMPLE PROJECT
****************************************
1
MARKING SCHEME -LAB
2
PYTHON RECORD PROGRAM LIST.
1. Write a menu driven program to find area of rectangle, square and
triangle.
2. Write a menu driven program to check whether the number is
Palindrome or Armstrong.
3. Write a python program to read a list of numbers. From this find the
average of the list, frequency of particular number from the list,
highest number and lowest number in the list
4. Write a program to create a dictionary from a list of marks based on
the following condition. Key as grade and data value as number of
students in each category.
Mark range Grade
>=80 Distinction
60-79 FirstClass
50-59 SecondClass
40-39 Pass
<40 Fail
5. Write a program to read a list of numbers. From this find the sum of
all the even numbers and odd numbers present in the list.
6. Write a program to read a string, find reverse of the string and count
number of upper case letters, lower case letters, blank spaces present
in the string.
7. Write a python program to create a random number from 1 to 6.
The program will end when the output becomes 1.
8. Write a program to create a text file data.txt and count how many
vowels, consonants, digits, blank spaces, special characters,
uppercase and lower-case letters present in the file.
9. Write a program to create a text file story.txt. and count number of
occurrence of the letter P or p and number of occurrence of the
symbol * .
10. Write a program to create a text file data.txt and count number of
occurrences of the word the(Ignoring the case sensitiveness)
11. Write a program to create a text file story.txt. Then read the file and
print those lines begin with T.
12.Write a program to create a binary file student.dat, which stores
some student details rollno, name and mark . Then read the file and
print the details.
13.Write a program to create a binary file employee.dat, which
contains some employee details like name, designation, and salary.
3
After creating the file, read data from the file and print details of
teachers.
14.Write a program to add some employee details to a csv file, emp.csv
[employee details are empid, name, designation and salary]. Then read
and print employee details from the file.
15.Write a program to create a csv file which some student details to a
stud.csv file. [Student details are rollno, name, and mark].
Read the csv file and print the details of students with mark more
than 90.
16. Write a program to implement stack operations.
17. Write a program to read a list of country names from this push
those names having more than 5 letters to the stack and then pop
and display.
18.Write a program to Insert employee details [Empid, name and
salary] to Employee table using connectivity.
19.Write a program to read data from an employee table and display
details of employees with salary more than 15000
20.Write a program to increment the salary of Employees whose salary
less than 15000 by 5%.
21.Write a program to remove the details of employees whose empid is
given.
*************************************************************************
4
PYTHON RECORD PROGRAMS- CODE AND SCREEN SHOTS
1. Write a menu driven program to find area of rectangle, square and
triangle.
Code:
5
Output:
6
2. Write a menu driven program to check whether the number is
Palindrome or Armstrong
Code:
7
Output:
8
3. Write a python program to read a list of numbers. From this find the
average of the list, frequency of particular number from the list,
highest number and lowest number in the list
Code :
9
Output:
10
4. Write a program to create a dictionary from a list of marks based on
the following condition. Key as grade and data value as number of
students in each category.
Mark range Grade
>=80 Distinction
60-79 FirstClass
50-59 SecondClass
40-39 Pass
<40 Fail
Code:
Output:
11
5. Write a program to read a list of numbers from this find the sum of
all the even numbers and odd numbers present in the list.
Code:
Output:
12
6. Write a program to read a string , find reverse of the string and
count number of upper case letters, lower case letters , blank spaces
present in the string.
Code:
Output:
13
7. Write a python program to create a random number from 1 to 6. The
program will end when the output becomes 1.
Code:
Output:
14
8. Write a program to create a text file data.txt and count how many
vowels, consonants, digits, blank spaces, special characters,
uppercase and lower-case letters present in the file.
Code:
Output:
15
9. Write a program to create a text file story.txt. and count number of
occurrence of the letter P or p and number of occurrence of the
symbol * .
Code:
Output:
16
10.Write a program to create a text file data.txt and count number of
occurrences of the word the(Ignoring the case sensitiveness) Code:
Output:
11.Write a program to create a text file story.txt. Then read the file
and print those lines begin with T.
Code:
Output:
17
12.Write a program to create a binary file student.dat. Which stores
some student details rollno, name and mark . Then read the file
and print the details.
Code:
Output:
18
13.Write a program to create a binary file employee.dat, which
contains some employee details like name, designation, and salary.
After creating the file, read data from the file and print details of
teachers.
Code:
Output:
19
14.Write a program to add employee details to a csv file, “emp.csv”
[employee details are empid, name, designation and salary]. Then
read and print employee details from the file.
Code:
Output:
20
15.Write a program to create a csv file which some student details to a
stud.csv file. (student details are rollno, name, and mark).
Read the csv file and print the details of students with mark more
than 90.
Code:
Output:
21
16. Write a program to implement stack operations.
Code:
22
Output:
23
17.Write a program to read a list of country names from this push those
names having more than 5 letters to the stack and then pop and
display.
Code:
Output:
24
CONNECTIVITY PROGRAMS
18.Write a program to insert employee details [Empid, name and
salary] to Employee table using python sql connectivity.
Code:
Output:
25
19.Write a program to read data from employee table and display details
of employees with salary more than 15000.
Code:
Output:
20.Write a program to increment the salary of Employees whose salary
less than 15000 by 5%.
Code:
Output:
26
21.Write a program to remove the details of employees whose empid
is given.
Code:
Output:
27
SQL QUERIES
I. SQL QUERIES SET 1
Employee Table
Query 1:
Query to create the above Employee table.
Query 2:
Query to insert the above records to the Employee table.
28
Query 3:
Display the details of teachers.
Query 4:
Display details of Employees coming from Kollam with salary more than
15000.
Query 5:
Display details of Employees whose salary between 20000 and 30000
29
Query 6:
Display details of Employees ascending order of name.
Query 7:
Display details of Teachers in descending order of salary.
Query 8:
Display details of Teachers whose name begins with B.
30
Query 9 :
Display details of Teachers or clerks using In operator.
Query 10 :
Display different designations without duplication.
Query 11 :
Display each designation and number of employees in that designation.
Query 12:
Display each designation and highest salary in that designation.
Query 13:
Add one more column Gender.
31
Query 14:
Change the data type of column name as varchar(30)
Query 15:
Remove the column location from Employee table.
Query 16:
Rename the column salary as wages.
Query 17:
Increment the salary of all clerks by 500.
Query 18:
Remove the details of clerks.
32
II. SQL QUERIES SET 2
Student table
Dept Table
Query 1:
Create and Insert data to the Student table.
Query 2:
Create and insert data to the department table.
33
Query 3:
Join Two tables using cross join
Query 4:
Join two tables using equijoin.
34
Query 5:
Join two tables using natural join.
Query 6:
Display Name of student department name of students whose
department contains more than 30 students.
35
PRACTICE PROGRAMS
1. Write a program to check whether a number is palindrome or not
using function.
2. Write a program to check whether a number is Armstrong or not
using function.
36
3. Write a program to find factorial of a number using function.
4. Write a program to find frequency of particular element from a
list of numbers.
5. Write a program to read a list of country names from this push
those names having more than 5 letters to the stack and then pop
and display.
Code:
37
6. Write a program to read a list of numbers . from this even
numbers are pushed to a stack and pop and display the numbers
7. Write a program to read a list of numbers from this find the sum
of all the even numbers and odd numbers present in the list.
38
8. Write a program to create a dictionary from a list of marks based
on the following condition.
Mark range Grade
>=80 Distinction
60-79 FirstClass
50-59 SecondClass
40-39 Pass
<40 Fail
9. Write a program to read a string , find reverse of the string and
count number of upper case letters, lower case letters , blank
spaces present in the string.
Code:
39
10. Write a program to create a text file story.txt. and count number
of occurrence of the letter P or p and number of occurrence of the
symbol * .
11. Write a program to create a text file data.txt and count number
of occurrences of the word the(Ignoring the case sensitiveness)
40
12. Write a program to create a text file story.txt. Then read the
file and print those lines begin with T.
13. Write a program to create a binary file student.dat. Which
stores some student details rollno, name and mark . Then read
the file and print the details.
41
14.Write a program to add some employee details to a csv file, emp.csv
[employee details are empid, name, designation and salary]. Then
read and print employee details from the file.
42
SQL PRACTICE QUESTIONS.
1. Consider the Book table given below and write queries for the given
questions.
Bookid Title Author Price Publisher
100 C++ Sumitha 300 ABC
200 Python Preethi 350 XYZ
300 Java Sumitha 400 ABC
400 AI Guido Van 500 PQR
500 C++ Swammy 200 XYZ
1. Create and insert the given details to the Book table.
2. Display details of C++ books written by Sumitha
3. Display details in decending order of price.
4. Display details of books begins with J
5. Display different publisher names without duplication.
6. Display each publisher and number of books published by that
publisher.
7. Increment the price of ABC publisher’s books by 50.
8. Add one more column Dop(date_of_publishing) the book.
9. Remove the column publisher from Book table.
10. Display each author and highest price of book of that author.
2. Consider the Employee table and Dept table with given details
Employee table
Empid Name Designation Salary Deptid
E100 Deepa Teacher 20000 10
E200 Jeena Clerk 12000 20
E300 Liji Teacher 21000 30
E400 Kathu Accountant 20000 10
Department Table
Deptid Deptname
10 Commerce
20 Physics
30 Computer
40 Chemistry
1. Create and insert data to the above two tables.
2. Join two tables using cross join.
3. Join two tables using equi join
43
4. Join two tables using natural join.
5. Display details of Tecahers in Physics department.
6. Display details of employees in commerce department with
designation not a teacher.
7. Display details of teachers who are in commerce department and
salary > 15000.
**********************************************************************
44
SAMPLE PROJECT - SCHOOL MANGENET SYSTEM
#SAMPLE PROJECT FOR CLASS 12 COMPUTER SCIENCE
STUDENTS
# TOPIC : SCHOOL MANAGEMENT SYSTEM.
import mysql.connector as sc
#Function for Login
def Login():
user=input("Enter User Id :")
pas=input("Enter password:")
if user=="Admin" and pas=="test123":
Home()
else:
print("Incorrect User ID or Passowrd!!. Try Again ")
#Function for Home Page
def Home():
print("WELCOME TO MGM SCHOOL MANGEMNET SYSTEM ")
print("MENU ")
print("1. ADD NEW STUDENT DETAILS")
print("2. UPDATE STUDENT DETAILS")
print("3. SEARCH STUDENT DETAILS ")
print("4. ISSUE TC ")
print("5. REPORT")
op=int(input("Enter your option"))
if op==1:
AddStudent()
elif op==2:
ChangeStream()
elif op==3:
SearchStudent()
elif op==4:
IssueTC()
elif op==5:
Report()
else:
print("Invalid option")
45
#Function to Add Student details.
def AddStudent():
try:
con=sc.connect(host="localhost",user="root",password="mgm",
database="test12",charset="utf8")
cur=con.cursor()
rno=int(input("Enter Rollno:"))
name=input("Enter name of the student:")
stream=input("Enter stream:")
dob=input("Enter Date of birth:")
fname=input("Enter father's name :")
add=input("Enter address :")
pno=int(input("Enter phone number :"))
mark=int(input("Enter previous year mark :"))
query="insert into student values({},'{}','{}','{}','{}','{}',{},
{})".format(rno,name,stream,dob,fname
,add,pno,mark)
cur.execute(query)
print("Successfully Add Student detials!!!")
con.commit()
con.close()
except:
print("Error!!")
#Function to UPdate student details
def ChangeStream():
try:
con=sc.connect(host="localhost",user="root",password="mgm",
database="test12",charset="utf8")
cur=con.cursor()
rno=int(input("Enter Rollno of the student whose stream need
to update:"))
stream=input("Enter new stream:")
query="update student set stream='{}' where
rollno={}".format(stream,rno)
46
cur.execute(query)
con.commit()
print("Successfully change the stream of the student!!!")
con.close()
except:
print("Error!!")
#FUnction to Search student details
def SearchStudent():
try:
con=sc.connect(host="localhost",user="root",password="mgm",
database="test12",charset="utf8")
cur=con.cursor()
print("1. Serach Student by Rollno ")
print("2. Search student by name and stream")
op=int(input("Enter your option:"))
if op==1:
rno=int(input("Enter the student's rollno while taking
admission:"))
query="select * from student where rollno={}".format(rno)
cur.execute(query)
data=cur.fetchall()
for i in data:
print(i)
elif op==2:
na=input("Enter name of the student")
stream=input("Enter stream")
query="select * from student where name='{}
and stream='{}'".format(na,stream)
cur.execute(query)
data=cur.fetchall()
for i in data:
print(i)
con.close()
except:
print("Error!!")
47
#Function to IssueTc()
def IssueTC():
try:
con=sc.connect(host="localhost",user="root",password="mgm",datab
ase="test12",charset="utf8")
cur=con.cursor()
rno=int(input("Enter Rollno of the student who is taking TC:"))
query="delete from student where rollno={}".format(rno)
cur.execute(query)
print("Remove the student details from database !!!")
con.close()
except:
print("Error!!")
#Function for Report()
def Report():
try:
con=sc.connect(host="localhost",user="root",password="mgm",datab
ase="test12",charset="utf8")
cur=con.cursor()
print("1. Serach Whole Student details ")
print("2. Search student by stream")
op=int(input("Enter your option:"))
if op==1:
query="select * from student"
cur.execute(query)
data=cur.fetchall()
for i in data:
print(i)
elif op==2:
48
stream=input("Enter stream")
query="select * from student where
stream='{}'".format(stream)
cur.execute(query)
data=cur.fetchall()
for i in data:
print(i)
con.close()
except:
print("Error!!")
Login()
49
SCREEN SHOTS
Add Student details
Update Student details
Search Student details
50
Issue TC
SAMPLE PRACTICAL PAPER.
51
52
*******************************************************************
53