You are on page 1of 26

PMShri Kendriya Vidyalaya

D.I.A.T. Girinagar, Pune

PRACTICAL FILE
FOR AISSCE 2023-24 BOARD EXAMINATION
SUBJECT: COMPUTER SCIENCE (083)

SUBMITTED BY:
NAME: Adit Mishra
ROLL NUMBER: ___________________
CLASS: XII SCIENCE
CERTIFICATE

This is to certify that this practical file has been made by Adit
Mishra, a student of Kendriya Vidyalaya D.I.A.T. Girinagar,
Pune, Maharashtra studying in class XII SCIENCE. He has
completed his practical file in time under the guidance of
concerned teacher and with his own efforts. His initiative,
cooperation and participant during Computer Science 2023-24
practical classes were excellent.

I certify that this practical file is up to my expectations and as


per the guidelines issued by CBSE.

Teacher’s Signature External Examiner’s Signature Principal’s Signature


INDEX

Sr. No. Date Programs Page No.


1 WAP to show functionality 6
of a basic calculator using
functions
2 Write a function in python 7
which accept a number
from user to return True, if
the number is a prime
number else return False.
Use this function to print
all prime numbers from 1
to 100.
3 Write a function in python 8
which accept a list of
marks of students and
return the minimum mark,
maximum mark and the
average marks. Use the
same function to test.
4 WAP to read a text file 9
“myfile.txt” line by line
and display each word
separated by a #.
5 WAP to read a text file 10
“myfile.txt” and display
the number of vowels/
consonants/ uppercase/
lowercase characters in the
file.
6 Remove all the lines that 11
contain the character ‘a’ in
a file and write it to
another file.
7 Write a program to create 12
a text file and print the
lines starting with ‘T’ or
‘P’. (Both uppercase and
lowercase).
8 Read a text file to print the 13
frequency of the word ‘He’
and ‘She’ found in the file.
9 Create a binary file with 14
name and roll number.
Search for a given roll
number and display the
name, if not found display
appropriate message.
10 Create a binary file with 15
roll number, name and
marks. Input a roll number
and update the marks.
11 Read a CSV file from hard 16
disc and print all the
details on the screen.
12 Read a CSV file 17
(containing item no, name,
rate, QOH) from hard disc
and print all the items
whose rate is between Rs
500 and Rs 1000.
13 Write a random number 18
generator that generates
random numbers between
1 and 6 (simulates a dice).
Throw the two dices for 10
times and print their total.
14 WAP in Python to 19
demonstrate linear search
15 Write a Python program to 20
implement a stack using a
list data-structure.
16 WAP to connect Python 22
with MySQL using
database connectivity and
perform the following
operation on data in
database: Create a table in
database
17 WAP to connect Python 23
with MySQL using
database connectivity and
perform the following
operation on data in
database: Insert record in
the table
18 WAP to connect Python 24
with MySQL using
database connectivity and
perform the following
operation on data in
database: Fetch records
from the table using
fetchone(), fetchall() and
fetchmany( ).
19 WAP to connect Python 25
with MySQL using
database connectivity and
perform the following
operation on data in
database: Update record in
the table
20 WAP to connect Python 26
with MySQL using
database connectivity and
perform the following
operation on data in
database: Delete record
from the table
AIM 1: WAP to show functionality of a basic calculator using
functions

OUTPUT :
AIM 2: Write a function in python which accept a number from user
to return True, if the number is a prime number else return False. Use
this function to print all prime numbers from 1 to 100.

OUTPUT:
AIM 3: Write a function in python which accept a list of marks of
students and return the minimum mark, maximum mark and the
average marks. Use the same function to test.

OUTPUT:
AIM 4: WAP to read a text file “myfile.txt” line by line and display
each word separated by a #.

Content in ‘file.txt’:

NOTE: This file contains 3 lines only.

OUTPUT:
AIM 5: WAP to read a text file “myfile.txt” and display the number of
vowels/ consonants/
uppercase/ lowercase characters in the file.

File content:
Same as above .txt file

OUTPUT:
AIM 6: Remove all lines that contain the character ‘a’ in a file and
write it in another file.

File content in file 1:

File content after running the above program in file 2:


AIM 7: Write a program to create a text file and print the lines
starting with ‘T’ or ‘P’
(both uppercase and lowercase).

File content:

OUTPUT:
AIM 8: Read a text file to print the frequency of the word ‘He’ and
‘She’ found in the file.

File content:

OUTPUT:
AIM 9: Create a binary file with name and roll number. Search for a
given roll number and display the name, if not found display
appropriate message.

OUTPUT:
AIM 10: Create a binary file with roll number, name and marks.
Input a roll number and update the marks.

OUTPUT:
AIM 11: Read a CSV file from hard disc and print all the details on
the screen.

OUTPUT:
AIM 12: Read a CSV file (containing item no, name, rate, QOH) from
hard disc and print all the items whose rate is between Rs 500 and Rs
1000.

File content of csv file:

OUTPUT:
AIM 13: Write a random number generator that generates random
numbers between 1 and 6 (simulates a dice). Throw the two dices for
10 times and print their total.

OUTPUT:
AIM 14: WAP in Python to demonstrate linear search.

OUTPUT:
AIM 15: Write a Python program to implement a stack using a list
data-structure.

Rest of the code on next page.


OUTPUT:
AIM 16: WAP to connect Python with MySQL using database
connectivity and perform the following operation on data in database:
Create a table in database

Database before running the program:

Database after running the program:


AIM 17: WAP to connect Python with MySQL using database
connectivity and perform the following operation on data in database:
Insert record in the table

Table after executing the program:


AIM 18: WAP to connect Python with MySQL using database
connectivity and perform the following operation on data in database:
Fetch records from the table using fetchone(), fetchall() and
fetchmany( ).

For fetchone():

OUTPUT:

For fetchmany():

OUTPUT:

For fetchall():

OUTPUT:
AIM 19: WAP to connect Python with MySQL using database
connectivity and perform the following operation on data in database:
Update record in the table

Table before executing the program:

Table after executing the program:


AIM 20: WAP to connect Python with MySQL using database
connectivity and perform the following operation on data in database:
Delete record from the table

Table before executing the program:

Table after executing the program:

You might also like