0% found this document useful (0 votes)
5 views34 pages

Program File 121

The document is a project report by Arvind Dangoliya from Pushpa Sr. Sec. School for the academic year 2024-2025, focusing on various computer science programs. It includes acknowledgments, a certificate of completion, an index of programs, and detailed code implementations for tasks such as calculating simple interest, swapping numbers, and handling file operations. The project showcases a range of programming concepts and database interactions using Python and SQL.
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)
5 views34 pages

Program File 121

The document is a project report by Arvind Dangoliya from Pushpa Sr. Sec. School for the academic year 2024-2025, focusing on various computer science programs. It includes acknowledgments, a certificate of completion, an index of programs, and detailed code implementations for tasks such as calculating simple interest, swapping numbers, and handling file operations. The project showcases a range of programming concepts and database interactions using Python and SQL.
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

Pushpa Sr. Sec.

School
Pushpa Sr. Sec. School

Ashta
ASHTA
2024-2025
2024-2025
2024-2025

Computer Science Project


ComputerPrograms
Sciencefile Project
Programs file
Arvind dangoliya Mr. Rajesh Mewada
Roll no. 03 PGT Computer science
Submitted by : Submitted to:
Class 12 th PCM
Arvind Dangoliya Mr. Rajesh Mewada
Roll no. PGT Computer science
Class 12 th PCM
Acknowledgement
I would like to express my special gratitude to
[Link] Mewada my Computer Science
Teacher And Fr. Melvin CJ, Principal of the
Pushpa Sr. Sec . School Ashta, who gave me
this golden opportunity to make a project and
for their help and immense guidance in the
completion my project for the academic year
[Link] is only due to their efforts that
my project could be successfully could be
completed. I came to know about so many
things from this project. Their valuable
suggestions, motivation and encouragement
has helped me throughout this project.

Arvind dangoliya
12 th “PCM”
Certificate
This is to certify that Arvind dangoliya of
th
class 12 “A” of Pushpa Sr. Sec. School
Ashta has completed his project file under
my supervision. He has taken keen interest
and shown utmost sincerity in completion
of this project. He has successfully
completed the project for the academic
year 2024-2025. And this project is upto
my satisfaction and as per the guidelines
issued by CBSE.

Internal’s Signature Principal’s Signature

External’s Signature
INDEX
[Link] to calculate simple interest using a
function.
[Link] To Swap Two Numbers Using Function.
[Link] To Create A Module "Temperature
Conversion" That Stores Functions For Various
Temperature Conversion.
[Link] To Read A Text Line By Line And Display
Each Word Seperated By # Sign.
[Link] To Accept Student ID, Name And Country
From the User And Store It Into External CSV File.
[Link] To Create Binary File With The Name And
Roll No. Such That It Searches For Name And Roll No. And
Displays if not Found.
[Link] To Create A Binary File With Roll no. Name
and marks. Enter the roll no. and Update Marks.
[Link] for creating a text file with some names
separated by newline character, without using write
function.
[Link] To Implement Stack Operations.
[Link] To Implement Stack Operation For The
Book Details(Book no, Book Name).Just Implement Push
And Display Operation.
[Link] to extract first n rows from the emp
relation using fetchmany.
14. Write a program to insert , update and delete from
python through CRUDE operation.
[Link] to search for specific employee
information based on employee id from a relation.
[Link] to display entire data from emp table
using tabulate.
15. Given the following student relation:
16. Consider the following DEPT and WORKER tables.
Write SQL queries for (i) to and (iv) find outputs for SQL
queries (v) to (viii) :
[Link] to calculate simple interest using a function.

def si(P,T,R):

return P*T*R

p=float(input("Enter Principal Amount :"))

t=float(input("Enter Time Period :"))

r=float(input("Enter Rate of interest :"))

y=si(p,t,r)

print("Simple Interest :",y)

Output
2. Programme To Swap Two Numbers Using Function.
def swap(a,b):

a,b=b,a

print("After swap value of x and y :",a,b)

x=int(input("Enter first no. :"))

y=int(input("Enter second no. :"))

print("Before swap value of x and y :",x,y)

swap(x,y)

Output
[Link] To Create A Module "Temprature Conversion"
That Stores Functions For Various Temprature Conversion.
def convert(temp):

print('[Link] to Celcius')

print('[Link] to Fahrenheit')

choice=int(input("Enter your Choice - 1 or 2 :"))

if choice==1:

print("Convert from Fahrenheit to Celcius:", (temp-32)*5/9,"C")

elif choice==2:

print("Convert from Celcius To Fahrenheit:", (temp*9/5)+32,"F")

else:

print("Choice is Invalid: ")

temp=float(input("Enter Temp To Be Converted :"))

convert(temp)

Output
4. Programme To Read A Text Line By Line And Display
Each Word Seperated By # Sign
f=open('[Link]','r')

content=[Link]()

for line in content:

words=[Link]()

print(words+"#",end='')

print("")

Output
[Link] To Accept Student ID, Name And Country
From the User And Store It Into External CSV File.
import csv

with open("[Link]","a+")as cs:

csvv=[Link](cs)

ans="y"

while ans=="y" or ans=="Y":

S_id=input("Enter student id :")

name=input("Enter student Name:")

country=input("Enter student's Country:")

[Link]([S_id,name,country])

ans=input("Do You Want To Input More Details(y/n):")

[Link]=(0)

[Link]=[Link](cs)

for line in csv_reader:

print(line)

[Link]()

Output
6. Programme To Create Binary File With The Name And
Roll No. Such That It Searches For Name And Roll No.
And Displays if not Found.
import pickle
x=open("[Link]",'w+b')

m=int(input("Enter no. of students:"))

details=[]

for i in range(m):

roll=int(input("Enter roll no. of student :"))

name=input("Enter name of student :")

cl=int(input("Enter class of Student :"))

[Link]([roll,name,cl])

[Link](details,x)

[Link](0)

y=[Link](x)

flag=0

roll=int(input("Enter roll no to be searched for students data :"))

for i in y:

if roll==i[0]:

flag=1 print("Roll no. name class")

print(i)

if flag==0:
print("Record Not Found !!!! ")

[Link]()

Output
[Link] To Create A Binary File With Roll no. Name and
marks. Enter the roll no. and Update Marks
import pickle

def write():

bf=open('P_6Binary_file.dat','wb')

dic={}

while True:

roll=int(input('Enter roll number :'))

name=input('Enter name:')

marks=int(input('Enter Marks:'))

dic[roll]=[name,marks]

ans=input('Do you want to enter more(y/n):')

if ans=='y' or ans==' Y':

continue

else:

break

[Link](dic,bf)

[Link]()

def update():

bd=open('P_6Binary_file.dat','r+b')

a=[Link](bd)

[Link]()
roll=int(input('Enter roll number to update:'))

if roll not in [Link](): print('Data not found!')

else:

bd=open('P_6Binary_file.dat', 'w+b')

mark=int(input('Enter New Marks:'))

a[roll][1]=mark [Link](a,bd)

[Link]()

[Link](0)

print('Successfully updated marks.')

r='Ok'

try: r=[Link](bd)

except EOFError:

pass

print(r)

[Link]()

write()

update()

Output
8. Programme for creating a text file with some names
separated by newline character, without using write
function.
names=['Akshay\n','Rishi\n', 'Mridul\n',’,'Sparsh\n','Aditi\n']
A=open('NAMES_file.txt','w')
[Link](names)
[Link]()
Output:
9. Program To Implement Stack Operations.
def isEmpty(stk):
if stk==[]:
return True
else:
return False
def Push(stk,item):
[Link](item)
top=len(stk)-1
def Pop(stk):
if isEmpty(stk):
return 'Underflow'
else:
item=[Link]()
if len(stk)==0:
top=None
else:
top=len(stk)-1
return item
def Peek(stk):
if isEmpty(stk):
return 'Underflow'
else: top=len(stk)-1
return stk[top]
def Display(stk):
if isEmpty(stk):
print("Empty Stack!")else:
top-len(stk)-1
print(stk[top],' TOP')
for i in range(top-1,-1,-1): print(stk[i])
if_name_=='_main_':
Stack=[]
top=None
while True:
print('STACK OPERATIONS')
print('[Link]')
print('[Link]')
print('[Link]')
print('[Link]')
print('[Link]')
ch=int(input('Enter choice (1-5):'))
if ch==1:item=int(input('Enter item:'))
Push(Stack, item)
elif ch==2:
item=Pop(Stack)
if item=='Underflow':
print('Stack is Empty.')
else: print('Popped item is: ',item)
elif ch==3:
item=Peek(Stack)
if item=='Underflow':
print('Stack is Empty.')
else:
print('Item on Top is ',item)
elif ch==4:
Display(Stack)
elif ch==5:
break
else:
print('Invalid Option!'
Output)
10. Programme To Implement Stack Operation For The Book
Details(Book no, Book Name). Just Implement Push And
Display Operation.
def isEmpty(stk):
if stk==[]:
return True
else:
return False
def Push(stk, item):
[Link](item)
top=len(stk)-1
def Display(stk):
if isEmpty(stk):
print('Empty Stack!')
else:
top=len(stk)-1
print(stk[top],' <<--TOP')
for i in range(top-1,-1,-1):
print(stk[i])
if_name_=='_main_':
Stack=[]
top=None
while True:
print('STACK OPERATIONS FOR Book details.')
print('[Link]')
print('[Link]')
print('[Link]')
ch=int(input('Enter choice (1-3):'))
if ch==1:
book_no=int(input('Enter Book No.:'))
book_name=input('Enter Book Name:')
Push(Stack, [book_no,book_name])
elif ch==2
Display (Stack)
elif ch==3:
break
else:
print("Invalid Option!")

Output
[Link] to extract first n rows from the emp relation
using fetchmany.
import mysql .connector as ms

a=ms..connect(host='localhost', user='root', password='root', database= 'emp1')

cr=[Link]()

[Link]('select * from emp')

dat=[Link]()

print(tabulate(dat, ['employee_id', 'Name', 'Mobile_no'], tablefmt='grid'))

Output
[Link] to display entire data from emp table using
tabulate.
import [Link] as ms

from tabulate import tabulate

a=ms..connect(host='localhost',user='root',password='ROOT',database= 'emp1')

cr=[Link]()

[Link]('select * from emp1')

dat=[Link]()

print(tabulate(dat,['employee_id','Name','Mobile_no'],tablefmt='grid'))

OUTPUT
[Link] to search for specific employee information
based on employee id from a relation
import [Link] as ms

a=ms..connect(host='localhost', user='root', passwd='root', database='e mp1')

cr=[Link]()

n=int(input('Enter Employee id:'))

[Link]('select * from emp where employee_id={}'.format(n))

dat=[Link]()

if dat==[]:

print('No employee information found.')

for i in data:

print(i)

Output
[Link] to perform insert, update and delete using
crude operation
import [Link] as myql
a=[Link](host='localhost', user='root', passwd='root', database='e mp1')
cr=[Link]()
def insert():
e_id=int(input('Enter employee id:'))
name=input('Enter employee name:')
mb=int(input('Enter mobile number:'))
try:
[Link]("insert into emp values({},'{}',{})".format(e_id,name, mb))
[Link]()
print('Values inserted.')
except:
print('An error occured during insertion.')
def update():
e_id=int(input('Enter employee id:'))
print('What do you want to update\[Link]\[Link] number')
opt=int(input('CHOICE(1,2):'))
if opt==1:
name=input('Enter employee new name:')
[Link]("update emp set name='{}' where
employee_id={}".format(name,e_id))
elif opt==2:
mb=input('Enter new mobile number:')
[Link]("update emp set mobile_no='{}' where
employee_id={}".format(mb,e_id))
if [Link]==0:
print('No existing employee id match.')
else: print('Updated successfully')

def delete():
e_id=int(input('Enter employee id to delete:'))
[Link]("delete from emp where employee_id={}".format(e_id))
print('Employee information deleted successfully.')
while True:
print('Employee CORNOR.')
print('Choose from the following.')
print('[Link]')
print('[Link]')
print('[Link]')
print('[Link]')
ch=int(input('CHOICE(1-4) :'))
if ch==1:
insert()
elif ch==2:
update()
elif ch==3:
delete()
elif ch==4:
break
else:
print('Wrong Option.')
Output
Q 15 Given the following Student relation
Student relation

No Name Age Department Date of fee Sex


adm
1 Pankaj 24 Computer 11/0197 120 M
2 Shalini 21 History 24/03/98 200 F
3 Sanjay 22 Hindi 12/12/96 300 M
4 Sudha 25 History 01/07/99 400 F
5 Rakesh 22 Hindi 05/09/97 250 M
6 Shakeel 30 Hisitory 25/06/98 300 M
7 Shourya 34 Computer 25/02/97 210 M
8 Shikha 23 Hindi 31/07/97 200 F

Write SQL commands for (a) to (f) and write output for (g).
(a) To show all information about the students of History department
(b) To list the names of female students who are in Hindi department
(c) To list names of all students with their date of admission in ascending order.
(d) To display student's Name, Fee, Age for male Students only.
(e) To count the number of student with Age <23.
(F)(To inset a new row in the STUDENT table with the following data:
9, "Zaheer", 36, "Computer", [12/03/97), 230, "M"
(g) Give the output of following SQL statements:
(i) Select COUNT (distinct department) from STUDENT;
(ii) Select MAX (Age) from STUDENT where Sex = "F";
(iii) Select AVG (Fee) from STUDENT where Dateofadm < (01/01/98);
(iv) Select SUM (Fee) from STUDENT where Dateofadm < (01/01/98):
Solution:-
(a) SELECT FROM Student
WHERE Department = "History";
(b) SELECT Name FROM Student
WHERE sex "F" and
Department "Hindi";
(c) SELECT name FROM Student
ORDER BY Dateofadm ;
(d) SELECT Name, Fee,
Age FROM Student
WHERE sex "M";
(e) SELECT COUNT(*) FROM Student
WHERE Age < 23;
(f) INSERT INTO Student VALUES
(9, "Zaheer", "Computer", "12/03/97", 230, "M");
(g) (i) 3 (ii) 25 (iii) 216 (iv) 1080
16 .Consider the following DEPT and WORKER tables. Write SQL queries for (i) to
and (iv) find outputs for SQL queries (v) to (viii) :
Table:DEPT

DCODE DEPARTMENT CITY


D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI

Table:WORKER

WNO NAME DOJ DOB GENDER DCODE


1001 George k 2013-09-02 1991-09-01 MALE D01
1002 Ryma sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-9-4 MALE D05
1007 Anil jha 2014-1-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 R Sahay 2013-11-18 1987-3-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05

Note. DOJ refers to date of joining and DOB refers to date of birth of workers .
(i)To display Wno, Name, Gender from the table WORKER in descending order of
Wno
(ii) To display the Name of all the FEMALE workers from the table WORKER
(iii) To display the Wno and Name of those workers from the table WORKER who
are born between
1967-01-01' and '1991-12-01"
(iv) To count and display MALE workers who have joined after 1986-01-01
(v) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE HAVING
COUNT()>1;
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
(vii) SELECT NAME, DEPARTMENT, CITY FROM WORKER W, DEPT DWHERE
[Link] AND WNO<1003;
Solution:-
(i) SELECT NO, NAME, Gender,
FROM WORKER

ORDER BY WINO Desc;

(ii) SELECT NAME FROM WORKER


WHERE GENDER= ‘FEMALE';
(iii) SELECT WNO, NAME
FROM WORKER
WHERE DOB BETWEEN ‘1987-01-01' AND '1991-12-01';
(iv) SELECT count(*)
FROM WORKER
WHERE GENDER= ‘MALE’ AND DOJ> '1986-01-01';
(v) COUNT (*) DCODE
2 D01
2 D05
(vi) DISTINCT DEPARTMENT
MEDIA
MARKETING
INFRASTRUCTURE
FINANCE
HUMAN RESOURCE
(vii) NAME DEPARTMENT CITY
George K MEDIA DELHI
Ryma Sen INFRASTRUCTURE MUMBAI
(viii) Max(DOJ) Min(DOB)
2014-06-09 1984-10-19

You might also like