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

Nalin PRACTICAL PRINT 2025

Uploaded by

nalinm0925
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Nalin PRACTICAL PRINT 2025

Uploaded by

nalinm0925
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

JSS PUBLIC SCHOOL

OOTY

PRACTICAL FILE
2024-2025
COMPUTER SCIENCE

~ Nalin Manickam
CLASS XII A
CERTIFICATE

Name : Nalin Manickam


Roll no. :
Institution : JSS PUBLIC SCHOOL, OOTY

This is to certify that NALIN MANICKAM of Class XII B has prepared


the report on the Project entitled
“FLIGHT MANAGEMENT” in computer laboratory during the academic
year 2024 – 2025 .

The report is the result of his efforts & endeavors. The


Report is found worthy of acceptance as final project report for the subject
Computer Science of Class XII. He has
prepared the report under my guidance.

___________________________
INTERNAL’S SIGNATURE

___________________________
EXTERNAL’S SIGNATURE

___________________________
PRINCIPAL’S SIGNATURE
ACKNOWLEDGEMENT

I would like to express a deep sense of thanks & gratitude to my


project guide Mrs. Hema Mam ( Computer Science ) for guiding
me immensely through the course of the project. She always
evinced keen interest in my work. Her constructive advice &
constant motivation have been responsible for the successful
completion of this project. My sincere thanks goes to Mrs. Anita
Ramesh, Our Principal Mam, for her co-ordination in extending
every possible support for the completion of this project.I also
thanks to my parents and my friends for their motivation &
support.I must thanks to my classmates for their timely help &
support for compilation of this project.Last but not the least, I
would like to thank all those who had helped directly or
indirectly towards the completion of this project.
INDEX
S.No Page Date Signature
TITLE No.

PYTHON
1. THE AREA OF VARIOUS SHAPES

2. LIBRARY FUNCTIONS

3. CREATING MODULES AND PACKAGES

4. SIMULATING A DICE RANDOMLY

5. WRITING AND READING DATA

REMOVE ALL THE LINES THAT CONTAIN A SPECIFIC


6.
CHARACTER

7. TO READ A TEXT FILE USING BUILT IN FUNCTIONS

8. FIND THE MOST COMMONLY OCCURING WORD IN A TEXT FILE

TO READ LINES FROM A FILE AND DISPLAY THE OCCURRENCE


9.
OF A SPECIFIC WORD

10. WRITING DATA TO A BINARY FILE

11. TO READ AND DISPLAY OPERATIONS ON A BINARY

12. UPDATING DATA TO A BINARY FILE

13. WRITING INTO CSV FILE

14. CREATING A CSV FILE

15. READ/WRITE/SEARCH OPERATIONS ON CSV FILE

16. ENCYPTION AND DECRPYTION


17. STACKS
TITLE
S.No Page Date Signature
No.

MySQL

1. CREATING TABLES AND INSERTING RECORD

2. TO ADD COLUMNS AND UPDATE TABLE

3. TO DELETE RECORD BASED ON CONDITION

4. EXTRACTING DATA

5. USING FUNCTIONS

6. USING OTHER FUNCTIONS

7. GROUPING DATA

8. SORTING DATA

9. INTERFACE PYTHON
PYTHON
PROGRAM-1 TO CALCULATE THE AREA OF VARIOUS SHAPES USING
FUNCTIONS
AIM: To easily calculate the area of different shapes and to reduce the program size
and calculations by using functions
def rectangle(x,y):
area=x"y
return area
def square(x):
area=x**2
return area
def circle(x):
area=3.14*x*x
return area
def triangle(x,y):
area=0.5*x*y
return area
y="yes"
while y=="yes":
print("MENU")
print("Which area do you want to find?")
print("1.Area of triangle")
print("2.Area of rectangle")
print("3.Area of square")
print("4.Area of circle")
x=int(input("enter your choice:"))
if x==1:
base=int(input("enter base of the triangle:"))
height=int(input("enter height of the triangle:"))
a=triangle(base,height)
print(a)
elif x==2:
l=int(input("enter length of the rectangle:"))
b=int(input("enter the breadth of the rectangle"))
a=rectangle(l,b)
print(a)
elif x==3:
s=int(input("enter the side of the square:"))
a=square(s)
print(a)
elif x==4:
r=int(input("enter the radius of the circle:"))
a=circle(r)
print(a)
y=input("do you want to continue? reply with yes/no")
OUTPUT:

PROGRAM-2 LIBRARY FUNCTIONS


AIM: To enable us to use various functions in the math and string module

import math
import string
y="yes"
while y=="yes":
print("MENU")
print("1.F 1.Functions in math module")
print("2.Functions in string module")
a=int(input("enter choice 1 or 2:"))
if a==1:
print("Choose the functions:")
print("1.sqrt")
print("2.exp")
print("3.pow")
print("4.sin")
print("5.cos")
print("6.radians")
b=int(input("choose a function:"))
if b==1:
x=int(input("enter the value to be calculated:"))
y=math.sqrt(x)
print(y)
elif b==2:
x=int(input("enter the value to be calculated:"))
y=math.exp(x)
print(y)
elif b==3:
x=int(input("enter value to be calculated:"))
a=int(input("enter power:"))
y=math.pow(x,a)
print(y)
elif b==4:
x=int(input("enter the value to calculated:"))
y=math.sin(x)
print(y)
elif b==5:
x=int(input("enter the value to calculated:"))
y=math.cos(x)
print(y)
elif b==6:
x=int(input("enter the value to calculated:"))
y=math.radians(x)
print(y)
elif a==2:
print("choose the functions:")
print("1.lower")
print("2.upper")
print("3.title")
print("4.find")
print("5.replace")
b=int(input("choose a function:"))

if b==1:
x=input("Enter the string:")
print(x.lower())
elif b==2:
x=input("Enter the string:")
print(x.upper())
elif b==3:
x=input("Enter the string:")
print(x.title())
elif b==4:
x=input("Enter the string:")
print(x.find(y))
elif b==5:
x=input("Enter the string:")
y=input("Enter word to be replaced:")
z=input("enter the new word:")
print(x.replace(y,z))
y=input("do you want to continue? (yes or no)")
OUTPUT :

PROGRAM-3 CREATING MODULES AND PACKAGES


AIM: To easily calculate Length conversions by importing modules
def miletokm(x):
return x*1.609344
def kmtomile(x):
return x/1.609344
def feettoinches(x):
return x*12
def inchestofeet(x):
return x/12
#Mass Conversion
def kgtotonne(x):
return x*0.001
def tonnetokg(x):
return x/0.001
def kgtopound(x):
return x*2.20462
def poundtokg(x):
return x/2.20462
OUTPUT :

from conversions import length_conversion as lc


lc.miletokm(15)
>>> 24.14016
lc.lmtomile(24.14016)
>>>15.0
lc.feettoinches(30)
>>>360

from conversions import mass_conversion as mc


mc.kgtopound(50)
>>>110.231
mc.kgtotonne(1000)
>>>1
mc.poundtokg(100)
>>>45.35929094356398

PROGRAM-4 SIMULATING A DICE RANDOMLY


AIM: To randomly pick numbers using the random module
import random
y="yes"
while y=="yes":
print("The number rolled is", random.randint(1,6))
y=input("Do you want to roll the dice again? Type yes to continue:")

PROGRAM-5 WRITING AND READING DATA FROM A FILE LINE BY LINE


AIM: To write the required data into the file and to read that written data line
by line.

f1=open("story.txt","w")
a=int(input("enter the limit:"))
for i in range(a):
name=input("enter name:")
f1.write(name)
f1.write("\n")
f1.close()
f1=open("story.txt","r")
for i in f1.readlines():
print(i)
f1.close()
PROGRAM-6 REMOVE ALL THE LINES THAT CONTAIN A SPECIFIC
CHARACTER IN A FILE AND WRITE IT INTO ANOTHER FILE
AIM: To write all the lines which do not contain a specific character into a new
file

f1=open("p.txt","r")
f2=open("book.txt","w")
X=""
c=0
for x in f1.read():
if "w" not in x:
f2.write(x)
f1.close()
f2.close()
f2=open("book.txt","r")
for i in f2.readlines():
print(i)
f2.close()
PROGRAM-7 TO READ A TEXT FILE USING BUILT IN FUNCTIONS
AIM: To display all the uppercase, lowercase, vowels, consonants and
special characters in the text file.
f1=open("poem.txt","r")
uc=lc=sc=sp=vo=co=0
for i in f1.read():
if i.isalpha():
if i.isupper():
uc+=1
if i in ['a', 'e', 'i', 'o','u']:
vo+=1
else:
co+=1
elif i.islower():
lc+=1
if i in ['a','e','i', 'o','u']:
vo+=1
else:
co+=1
else:
sp+=1
print("number of uppercase characters:",uc)
print("number of lowercase characters:",lc)
print("number of special characters:",sp)
print("number of vowels:",vo)
print("number of consonants:",co)
f1.close()
PROGRAM-8 FIND THE MOST COMMONLY OCCURING WORD IN
A TEXT FILE
AIM: To find the most commonly occurring word in a text file and
listing the frequencies of words in a text file
f=open("poem.txt","r")
contents=f.read()
wordlist=contents.split()
wordfeq=[]
high=0
word=""
existing=[]
for i in wordlist:
count=wordlist.count(i)
if i not in existing:
wordfeq.append([i,count])
existing.append(i)
if count>high:
high=count
word=i
print("the word",word,"occurs maximum times", high,"times")
print("\nother words have frequencies:")
print(wordfeq)

PROGRAM-9 TO READ LINES FROM A TEXT FILE AND DISPLAY


THE OCCURRENCE OF A SPECIFIC WORD
AIM: To read the file and to count the occurrence of a word that has
been given as the input.
file=open("poem.txt","r")
count=0
x=input("enter the word:")
for i in file:
words=i.split()
for w in words:
if w==x:
count+=1
print("the output is:",count)
file.close()
PROGRAM-10 WRITING DATA TO A BINARY FILE
AIM: To get student data(roll no, name, marks) from user and write
into a binary file.
import pickle
s={}
f=open("bin.dat", "wb")
choice="y"
while choice=="y":
rno=int(input("Enter your rollnumber:"))
marks=float(input("Enter mark:"))
name=input("Enter name:")
s['rno']=rno
s["marks"]=marks
s['name']=name
pickle.dump(s,f)
choice=input("Enter y to continue:")
f.close()
PROGRAM-11 TO READ AND DISPLAY OPERATIONS ON A
BINARY
FILE
AIM: To read and display students details from a binary file and search
for a record in a file.

import pickle
def read():
st={}
fin=open("bin.dat","rb")
try:
print("File bin.dat stores these records")
while True:
st=pickle.load(fin)
print(st)
except EOFError:
fin.close()
def display():
fin=open("bin.dat","rb")
found=False
a=int(input("Enter the record to be searched:"))
try:
print("Searching in file bin.dat")
while True:
st=pickle.load(fin)
if st['rno']==a:
print(st)
found=True
except EOFError:
if found==False:
print("No such records found in the file")
else:
print("search successfull")
fin.close()

ans="y"
while ans=="y":
print("MENU")
print("1.read and display the records")
print("2.search for records")
z=int(input("enter the function:"))
if z==1:
read()
if z==2:
display()
ans=input("Do you want to continue(y/n)")
PROGRAM-12 UPDATING DATA TO A BINARY FILE
AIM: To update the details of a student on a binary file using pickle.
import pickle
st={}
found=False
fin=open("bin.dat","rb+")
a=int(input("Enter roll no to be updated:"))
b=input("Enter the detail to be updated:")
try:
while True:
rpos=fin.tell()
st=pickle.load(fin)
if st["rno"]==a:
if b=="name":
c=input("Enter the new name:")
st[b]=c
found=True
elif b=="rno":
c=int(input("Enter the new rollno:"))
st[b]=c
found=True
elif b=="marks":
c=float(input("Enter the new marks:"))
st[b]=c
fin.seek(rpos)
pickle.dump(st,fin)
found=True
except EOFError:
if found==False:
print("sorry,no match found")
else:
print("record successfully updated")
fin.close()
fin=open("bin.dat","rb")
try:
while True:
st=pickle.load(fin)
print(st)
except EOFError:
fin.close()

PROGRAM -13 WRITING INTO CSV FILE


AIM: To create a csv file to store employee data (employee no, name,
designation, salary)
import csv
f=open("emp.csv","w")
empwriter=csv.writer(f)
empwriter.writerow(['empno', 'name', 'designation', 'salary'])
for i in range(3):
print("Employee record",i+1)
empno=int(input("Enter empno:"))
name=input("Enter name:")
designation=input("Enter the designation:")
salary=int(input("Enter salary:"))
emprec=[empno,name,designation,salary]
empwriter.writerow(emprec)
f.close()
PROGRAM-14 CREATING A CSV FILE
AIM: To get item details (code, description, price) for multiple items
from the user and create a csv file.
from csv import writer
def f_csvwrite():
f=open("goods.csv","w")
dt=writer(f)
dt.writerow(['code', 'description','price'])
|=[]
choice="y"
while choice=="y":
r=input("Enter code:")
b=input("Enter description:")
s=input("Enter price:")
l=[r,b,s]
dt.writerow(1)
choice=input("Enter y to continue:")
f.close()
f_csvwrite()
PROGRAM-15 READ/WRITE/SEARCH OPERATIONS ON CSV FILE
AIM: To create a menu driven program to write, read and search
records on a csv file.
from csv import reader
def f_csvread(b):
f=open(b,"r")
dt=reader(f)
data=list(dt)
f.close()
print(data)
from csv import writer
def f_cswrite(c):
f=open(c,"w",newline="")
dt=writer(f)
01-1
n=int(input("enter the number of fields:"))
for i in range(n):
x=input("field name")
l.append(x)
dt.writerow()
n=int(input("enter no. of records"))
for i in range(n):
print(input("enter data1"))
q=input("enter data2")
dt.writerow([p.ql)
f.close()
from csv import reader
def srch(m):
f=open(m,"r")
s=reader(f)
n=input("data to be searched")
print(s)
flag=0
for row in s:
for field in row:
if field==n:
print("record found")
print(row)
print("*********
flag-1
break
if flag==0:
print("record not found")
f.close()
while True:
print("CSV file functions")
print("1.to read a file")
print("2.to write a file")
print("3.to search for a record")
print("4.exit")
ch=int(input("enter your choice"])
if ch==1:
b=input("enter the csv file with the extension .csv")
f_csvread(b)
if ch==2:
c=input("enter the csv file to create with the extension.csv")
f_csvwrite(c)
if ch==3:
m=input("enter the csv file in which you want the row to be searched with the extension.csv")
srch(m)
if ch==4:
break

PROGRAM-16 ENCYPTION AND DECRPYTION


AIM: To encrypt and decrypt code.
def encrypt(strn,enkey):
return enkey.join(strn)
def decrypt(strn,enkey):
return strn.split(enkey)
mainstring=input("enter mainstring:")
encryptstr=input("enter encryption key:")
enstr-encrypt(mainstring, encryptstr)
dest=decrypt(mainstring, encryptstr)
destr="".join(dest)
print("The encrypted string is:",enstr)
print("The decrypted string is:", destr)
PROGRAM-17 STACKS
AIM: To create a stack
stk=[]
def display():
if stk==[]:
print("Stack empty")
else:
for x in range(len(stk)):
print(stk[x])
def push():
e_no=int(input("Enter employee number:"))
e_name=input("Enter employee name:")
e_sal=int(input("Enter employee salary:"))
l=[e_no,e_name,e_sal]
stk.append(l)
def pop():
if stk==[]:
print("Stack empty")
else:
item=stk.pop(-1)
print("Deleted element is:",item)
def peek():
if stk==[]:
print("Stack empty")
else:
item=stk[-1]
print("Peeked element :",item)

print("STACK OPERATION")
print("1.Display")
print("2.Push")
print("3.Pop")
print("4.Peek")
ch="y"
while ch=="y":
choice=int(input("enter your choice(1 to 5):"))
if choice==1:
display()
elif choice==2:
push()
elif choice==3:
pop()
elif choice==4:
peek()
break
else:
print('invalid choice')
ch=input("Enter y to cont q to quit")
MySQL
Part-1 : Data management

Practical - 1 : Creating table and inserting record

1. Create table department based on the following instance and populate the table.

Column Data type Constraints


Dept Int Primary key
D_name Varchar(20) Not null
HOD Int Default-5

OUTPUT:
2. Create table staff based on the following instance and populate the table.

Column Data type Constraints


S_no Integer Primary key
S_name Varchar(30) Not null
Salary Float N/A
Zone Varchar(15) N/A
Age Int Greater than 20
Grade Char(1) N/A
Dept Int Foreign key
(Dept table)

OUTPUT
Practical - 2 : To add columns and update table

1. Add a column manager_name in table department varchar(30) and update table


with appropriate data

OUTPUT

Practical - 3 : To delete records based on criteria

1. Delete all records from staff table belonging to south zone and having grade A

Source code :
OUTPUT :

2. To delete column Manager_name from table department

Source code :

OUTPUT :

Practical 4 :Extracting data

1. Display S_no, S_name, Salary and corresponding d_name of all employees whose
age is between 25 and 35 ( Both values inclusive )

SOURCE CODE:

OUTPUT:
2. Display d_name and correspoonding S_name from tables department and staff

SOURCE CODE:

OUTPUT:

3. Display S_name, Salary, Zone and income tax of all the staff with appropriate
column headings ( Income tax to be calculated as 30% of salary )

SOURCE CODE:

OUTPUT:

4. Display all details of staff of south zone whose salary is greater than 50000
SOURCE CODE:

OUTPUT:
5. Display S_name, age , grade of staff whose name starts with the character “J”

SOURCE CODE:

OUTPUT:

Practical 5 : Using Functions


1. Display maximum salary and minimum salary from table employee under
appropriate column headings

2. Display the average and total salary from staff

3. Count the number of records in the table staff


4. Count the number of distinct zones from table staff

Practical-6:

1. Display d_name of table department in uppercase

2. Remove leading and trailing spaces from d_name field of department table

3. Concatenate d_name and dept of table department having d_name as “Computer”


4. Display first three characters extracted from d_name column of table department
whose is not in dept 33

Practical-7 : Grouping data

1. Display grade-wise total salary.

2. Display the maximum and minimum salary in each zone

3. Display department-wise aveerage salary having an average salary less than


100000
4. Display department-wise average salary having dept count less than or equal to 2

Practical-8: Sorting Data

1. Display names from table employee in ascending order.

2. Display all the details of employees in ascending order of age from table employee.

3. Display all the details of employee in descending order of grade and then by
ascending order of age from table employee
4. Display name and age of employee in ascending order or names where age is
between 20 and 40

Practical 9: Create table with constraints


AIM: To create table “Students” in mysql by mentioning the constraints.

Field name Data type Null/Not Null/Unique/Default Primary key


No int PRI KEY
Name char(20) Unique
Stipend Int Not null
Stream Char(20) Default -> “Non - Medical”
Avgmark Float Not null
Grade Char(1) Not null
Class Char(4) Not null

SOURCE CODE :

INSERTING VALUES :
Describe table :

Distinct on any field :

Where clause using between :

Where clause using like :

Where clause using asc and desc :


Where clause using “!=”

Where clause using ”and” :

Where clause using relations :

Using function average( Avg ) :

Using function concat :


Using function(lower()) :

Using function(max()) :

Using function(min()) :

Using function(round())

Using function(sqrt())
Using function(sum())

Using function(upper()) :

GROUP BY :

CONDITION BASED :

Practical 10 : JOINS
Non-equi joins : a non-equi join is a query that specifies some relationship other than
equality between the columns

Create Table

Inserting Values :

Display employees details as name , Salary, Zone, Grade only for east zone by
comparing Isal and Hsal

CARTESIAN PRODUCT :
Equi-join : The join in which the columns are compared for equality . All the columns
would appear in the table being joined are included even if identical.

NATURAL JOIN :
Natural join is to avoid identical columns being replicated (no on clause required )

Natural join employee and department where grade=”A”

Write query to print all the fields where salary is greater than 60000 and grade=B
The result of “using“ clause is natural join and non-equi join :

Inner join :

Left join :

Right join :
INTERFACE PYTHON

1. Using the concept of interface python create a menu driven program to create
table, insert records and fetch records in sql

SOURCE CODE:
OUTPUT :

2.updating
OUTPUT :

Practical-4 Searching data from a sql table

Source code:
Output:

Practical -5 Deleting data from sql table:

Source code:

Output:

You might also like