We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 26
CARMEL CONVENT H.S. SCHOOL
Aproject report in Computer Science (083)
submitted in partial fulfilment of
the requirement for the completion of
CBSE 2024-25
BY
Krishna Dabi
CBSE Roll No.
Under the supervision of
Ms. POORNIMA PARATE
Teacher's Sign _— External’s Sign __—Principal’s SignACKNOWLEDGENT
I would like to express my special thanks of gratitude
to my Teacher Ms. Poornima Parate Mam and my
Principal Sr. Mary who gave me this opportunity to
do this wonderful project file based on syllabus
practical. ] am really thankful to them.
Secondly, I would also like to thank my parents and
friends who helped me a lot in finishing this project.
THANK YOUCERTIFICATE
This is to certify that students Krish na D a bi
has satisfactorily completed the
laboratory work in Computer Science (083) Python
Programs of CBSE for the purpose of AISSCE
Practical Examination (2024-25) in Class XII to held
in Carmel Convent H.S. School.
Teacher’s sign External’s Sign Principal’s SignTABLE OF CONTENT
Serial Programs Page No. | Signature
No.
Write python program to add two numbers 1
through a function.
Write a python program to find area.
Write a python program to create all arithmetic
operation.
Write a python program to read the file.
Write a python program to read the file.
Write a python program to create a dictionary
containing names of competitions winner
student as key and number of their wins as
values.
Write a python program to create binary file.
Write a python program to create CSV file.
Write a python program to ensure that an
integer is entered as input and in case any other
value is entered, it displays a message- ‘Not
valid integer’
Write a program to accept two numbers and
display the quotient.
Write a program to find out even or odd
numbers.
Write a program to find out the Simple Interest.
Write a program to append a file.
Write a program to print cube of numbers in the
range 15 to 18.
Write a program to print square root.
Write a program that displays first three rows
fetched from student table of MySQL databases
“project”
Write a program to connect Python with MySQL
using database connectivity and perform
DELETE operation on table project.Write a program to connect Python with MySQL
using database connectivity and perform
UPDATE operation on table project.
Write a program to connect Python with MySQL
using database connectivity and perform
INSERT operation on table project.
Write a SQL commands for (1) to (v).Program 1 Write a python program to create all
arithmetic operation.
Program code:
def multi (x,y):
return ( (x+y), (x-y), (x*y), (x/y), (x%y))
ni=int (input ("enter num1:"))
n2=int (input ("enter num2 )
add, sub, mult, div, mod=multi (n1,n2)
print ("Sum of given numbers:", add)
print ("Subtration of given numbers:", sub)
print ("Product of given numbers mult)
print ("Division of given numbers:",div)
print ("Modulo of given numbers:",mod)
Output:
= RESTART: C:\Users\DELL\AppData\Loc
enter numl:420
enter num2:24
Sum of given numbers: 444
Subtration of given numbers: 396
Product of given numbers: 10080
Division of given numbers: 17.5
Modulo of given numbers: 12Program 2: Write a python program to read the file
my iPUOBTAM Ode: \ jj -cr5\DELL\Desktop\We work. txt", "2
x=myfile.read()
print (x)
= RESTAR rs/DELL/AppData/Local/Programs/Python/E
We work we try to be better
We work with full zest
But, why is that we just don't know any letter.
We still give best.
We have to steel
why is that we still don't get a meal.
We don't get luxury,
we don't get childhood,
But we still work,
Not for us, but for all the other
why is it that some kids wear shoes, BUT we make them ?Program 3: Write python program to add two numbers
through a function.
Program code:
def calcsum(a,b):
s=atb
return s
int (input ("enter first num:"))
(input ("enter second num:"))
salcsum(n1,n2)
print (add)
Output:
= RESTART: C:/Users/DEI
enter first num:257
enter second num:654
911Program 4: Write a python program to create a file
to hold some data.
Program code:
file=open("stud.data", "w")
for i in range(5):
name=input ("stud name:")
file.write (name)
file.close()
Output:
= RESTART: C:\Users\DE
stud name: Bhuvana
stud name:Megha
stud name:Vidhya
stud name: Kushal
stud name:Ram
B suadata
File Edit View
BhuvanaMeghaVidhyakushalRamProgram 5: Write a python program to create binary
file.
Program code:
import pickle
stu={}
stufile=open('Stu.dat', 'wb')
ans:
while an y
rno=int (input ("enter roll number
marks=input ("enter
stu['ROl1no']=rno
stu['Marks']=marks
pickle. dump (stu, stufile)
ans=input ("Want to enter more records?(y/n)..
stufile.close()
Output:
= RESTART: C:\Users\DELL\AppData\Local\.
enter roll number: 11
enter :Noor
Want to enter more records? (y/n)...y
enter roll number:12
enter: Pooja
Want to enter more records? (y/n).
enter roll number:13
enter:Raman
Want to enter more records? (y/n).
enter roll number:14
enter:Kamala
Want to enter more records? (y/n).
enter roll number:15
enter:Varun
Want to enter more records? (y/n)Program 6: Write a python program to create a
dictionary containing names of competitions winner
student as key and number of their wins as values.
Program code:
n=int (input ("How many students?"))
CompWinners
for i in range(n):
key=input ("Name of the student:")
value-int (input ("Number of competitions won:"
CompWinners[key]=value
print ("The dictionary now is:")
print (CompWinners)
Output:
= RESTART: C:/Users/DELL/Desktop/C.S. Project/cc
How many students?4
Name of the student :Navya
Number of competitions, wonr4
Name of the student:Nita
Number of competitions won:3
Name of the student:Rohit
Number of competitions won:2
Name of the student: Surya
Number of competitions won:3
The dictionary now is
{'Navya': 4, 'Nita': 3, 'Rohit': 2, 'Surya': 3Program 7 : Write a python program to find area
«Program code:
def area(L,B):
s=(L*B)
return s
x=int (input ("enter number:"))
y=int (input ("enter number:"))
qrarea (x,y)
print (q)
Output:
= RESTART: C:\Users\DEL
enter number: 482
enter number:
964Program 8: Write a python program to create CSV file.
Program code:
import csv
fh=open("Student.csv", 'w')
stuwriter=csv.writer (fh)
stuwriter.writerow(['Rollr ", 'Marks'])
for i in range(5):
print ("Student record", (i+1))
rollno=int (input ("enter rollno:"))
name=input ("enter name:")
marks=float (input ("enter marks:"))
sturec=[rollno, name,marks]
stuwriter.writerow(sturec)
fh.close ()
Output:
= RESTART: C:\Users\DE
Student record 1
enter rollno:101
enter name:Arjun
enter marks:78
Student record 2
enter rollno:102
enter name:Amar
enter marks:74
Student record 3
enter rollno:103
enter name:Bhuvana
enter marks:76
Student record 4
enter rollno:104
enter name:Chandrika
enter marks:73
Student record 5
enter rollno:105
enter name:Dimpy
enter marks:73Program 9: Write a python program to ensure that an
integer is entered as input and in case any other value
is entered, it displays a message- ‘Not valid integer’
Program code:
t ok:
numberString=input ("enter an intege:
n=int (numberString)
ok=T
xcept:
‘int("Error! Not a valid integer.
Output:
= RESTART: C:\Users\DELL\App
enter an integer:yg45
Error! Not a valid integer.
enter an integer:46Program 10 :Write a program to find out even or odd
numbers.
Program code:
def mode (n):
if (n$2==0
print ("even")
elif (n%3 QO):
print ("odd")
num=int (input ("enter a number:"))
mode=mode (num)
print (mode)
i
Output:
= RESTART: C:\Use
enter a number:45
oda
None
= RESTART: C:\Users\
enter a number:28
even
NoneProgram 11: Write a program to appenda file
.Program code:
fileout=open (
Listl=[]
for i in range(4):
name=input ("enter name:"
Listl.append(namet+'\n"')
fileout.writelines (List1)
fileout.close()
Output:
= RESTART: C:/Users/DELL/Ap
enter name:Noora
enter name:Vidhya
enter name:Varun
enter name:Rahul
| suee
File Edit View
Noora
Vidhya
varun
RahulProgram 12: Write a program to find out the Simple
Interest.
Program code:
def calcsum(P,R,T):
RAT
return s
def si(x,y,z):
sa=calcsum(x,y,Z)
return sa/100
ni=int (input ("enter principal:"))
n2=int (input ("enter
n3=int (input ("enter
rint (si(n1,n2,n3))
Output:
RESTART: C:\Users\DELL\.
enter principal:4200
enter rate:12
enter time:2
1008.0Program 13: Write a program to accept two numbers
and display the quotient.
Program code:
a=int (input ("enter value for a:"))
b=int (input ("enter value for b:"))
try:
if b==0:
ra ZeroDivisionError
print (a/b)
e ZeroDivisionError:
print("enter non-zero value for b.")
Output:
Python 3.11.9 (tags/v3.11.9:de
Type "help", "copyright", "cre
= RESTART: C:\Users\DELL\AppD:
enter value for a:45
enter value for b:0
enter non-zero value for b.Program 14: Write a program to print cube of
numbers in the range 15 to 18.
Program code:
for i in range(15,18):
print ("Cube of numbers", i,end='')
print ("is", i**3)
Output:
RESTART: C:/Users/DELL/Appl
Cube of numbers 15is 3375
Cube of numbers 16is 4096
Cube of numbers 17is 4913
Program 15: Write a program to print square root.
Program code:
xr i in range(1,18,2):
print ("Sq.root of",i 1 (i**0.5))
Output:
RESTART: C: /Users/DELL/AppData/L
of 1: 1.0
of 3 : 1.7320508075688772
of 5 t 2.23606797749979
of 2
of 3
of : :
of 05551275463989
of 15 983346207417
of : 105625617661Program 16: Write a program to connect Python with
MySQL using database connectivity and perform
UPDATE operation on table project.
cso
| Manage:
| Director
oUt ela er)
ce | Clerk pray
Cee ooo 13500
Tes Salesman put
|
risa | Manage: BU L1:):)
:/Users/DELL/Desktop,
UPDATION SUCCESSFULLY DONEProgram 17 : Write a SQL commands for (i) to (v).
EmpID | Firstname | Designation | Salary | Benefits
cos Courts I)
oss) Drea oer
| Sam Patro Clerk eT)
| Sarah Clerk CCT
cut SCE G) 13500
fuss Puce i) SULT)
asso Couette pu)
1 Select the EmpID, Salary whose is maximum.
nysql> select EmpID, Sala
ory
~> lihere Salary=(select max(Salary));
17980
UT
Pros)
ate
2500
ors Ey3. UPDATE Employee's Salary by 15%.
rere
Cree)
DEE
Oa
Peuesy urea)
Director Str
11270 Ea)
rer) rd
ron ery
uns ae ptr]
pears 19550
4. Count the number of Employee's whose salary is more than 35000.
mysql> select count(EmpID)
-> from pro
-> where Salary>35000;
+
| count(EmpID) |
5. Find those Employee's whose salary + benefit is minimum.
eee SOR etc
Seer a
Sen Seer ea CHIC
‘
Soe mtr
oes)
Lato aProgram 18: Write a program to connect Python with
MySQL using database connectivity and perform
INSERT operation on table project.
EmpID | Firstname | Designation | Salary | Benefits
CEUEt! cE
|
Uy |
152
215 ri eo
|
pC Pricer
aoa) Been)
9 Pret
13500
pYCry
Burry)Program 19: Write a program to connect Python with
MySQL using database connectivity and perform
Delete operation on table project.
stname | Designation | Salary | Benefits
| George | Manager
micssd | Director
am Patro | Clerk
ec | Clerk
| Hanya ieee
| Hennry | Salesman
caasa | Manager
" ,paseword="
EnpiD=? 415 (EmpID)
or -execute(query
commit ()
at (error)
Output:
= RESTART: C:/Users/DELL/Deskt
enter ID:10
DELETION SUCCESSFULLY DONEProgram 20: Write a program to connect Python with
MySQL using database connectivity and perform
Delete operation on table project.
stname | Designation | Salary | Benefits
| George | Manager
micssd | Director
am Patro | Clerk
ec | Clerk
| Hanya ieee
| Hennry | Salesman
caasa | Manager
" ,paseword="
EnpiD=? 415 (EmpID)
or -execute(query
commit ()
at (error)
Output:
= RESTART: C:/Users/DELL/Deskt
enter ID:10
DELETION SUCCESSFULLY DONEProgram 21: Write a program that displays first three
rows fetched from student table of MySQL databases
“project”
| EnpID | Firstname | Designation | Salary | Benefits
corer Tet sd cE
eae Pieris Pe
oes PE
er I
ey Serra 13500
oe eee UI
acs Manager ULI)
Output:
RESTART: C:/Users/DELL/AppData/Loca
(105, 'Merry', 'Director', 51750, 17250)
(152, 'Sam Patro', 'Clerk', 11270, 3000)
(215, 'Sarah', 'Clerk', 11500, 3000)