Cp. Muzzamil Practical
Cp. Muzzamil Practical
RIYADH
Computer Science
Practical Record
2023-24
MOHAMMED MUZZAMIL
Name:
Class: XII – A
Reg.No:
Date:
1 |Page
Laboratory Certificate
This is to certify that This COMPUTER SCIENCE PRACTICAL RECORD has been
successfully completed Master MOHAMMED MUZZAMIL of class XII - A under
the guidance of Mrs. Haseena Rizwan (COMPUTER SCIENCE) in particular
fulfillment of the curriculum of Central Board of Secondary Education
(CBSE) leading to the award of the annual examination of the year 2024-25
.
2 |Page
Signature of the Principal
Index
Sl.no Programs Date Teacher’s
Signature
1. Write a python program to search an
element in a list and display the frequency
of an element present in a list using function
(linear search).
2. Write a program with a function LShift(L,N)
which accepts a list L of numbers and N is a
numeric value by which all the elements of
the list are shifted to left.
3. Write a program with a function
DoubletheOdd(Nums) to add and display
twice of odd values from the list of Nums.
4. Write a python Program to search any word
in given string/sentence using function.
5. Write a Python program for random number
generation that generates random
Numbers between 1 to 6 (simulates a dice).
6. Write a program to read lines from a text
file and display those lines which start with
alphabet ’H’.
7. Write a program to count the word “to”
present in a text file.
3 |Page
8. Write a program to read the content of a file
and display how many uppercase characters
are present.
9. Write a program to remove all the lines that
contain the character ’a’ in a file and write it
to another file.
4 |Page
17. Create a CSV file by entering user id and
password, read and search the password for
given user id.
18. Write a program to implement a stack for
these book details (book no, book name).
That is now each item node of the stack
contains two types of information-a book
no. and its name. Just implement PUSH &
DISPLAY operations.
19. Write a program to implement all stack
operations (push, pop, peek& display) using
a list data structure.
20. Write the SQL commands for i) to v) & find
the outputs of the SQL queries (vi) to (viii)
based on the relations Teacher and Posting
given below:
21. Consider the following table STOCK
&DEALERS and write sql commands for
questions i) to iv) .
22. Write SQL queries for the following:
5 |Page
25. Write a Python-MySQL connectivity code to
insert the following records into a table
STUDENT created under the database
SCHOOL. Structure of the table STUDENT
26. Write a Python-MySQL connectivity code to
delete two rows from the above (already
created) table STUDENT.
Python
Program - 1
Write a python program to search an element in a list and
display the frequency of an element present in a list using
function (linear search).
Code:
6 |Page
• Output:
7 |Page
Program –
2
Write a program with a function LShift(L,N) which accepts a
list L of numbers and N is a numeric value by which all the
elements of the list are shifted to left.
Code:
• Output:
Program – 3
8 |Page
Write a program with a function DoubletheOdd(Nums) to add
and display twice of odd values from the list of Nums. Code:
• Output:
4
Write a python Program to search any word in given
string/sentence using function. Code:
9 |Page
Program –
• Output:
10| P a g e
Program –
5
Write a Python program for random number generation that
generates random Numbers between 1 to 6 (simulates a dice).
Code:
• Output:
6
11| P a g e
Program –
• Output:
7
Write a program to count the word “to” present in a text file.
Code:
12| P a g e
Program –
• Output:
8
Write a program to read the content of a file and display how
many uppercase characters are present. Code:
13| P a g e
Program –
• Output:
9
Write a program to remove all the lines that contain the
character ’a’ in a file and write it to another file. Code:
14| P a g e
Program –
• Output:
10
15| P a g e
Program –
Code:
• Output:
11
Write a program that reads a text file and then creates a new
file where each character's case is inverted.
Code:
16| P a g e
Program –
12
Write a program to read lines from a file poem.txt and
display all those words which has less than 4 characters in it.
Code:
17| P a g e
Program –
Text File: .
• Output:
13
Write a program to create a binary file ‘STUDENT.dat’ with name, roll
number and mark. Search for a given roll number and display the
name, if not found display appropriate message.
18| P a g e
Program –
Code:
19| P a g e
Program –
14
Write a program to create a binary file EMPLOYEE.dat with empno,
ename and salary. Input an employee number and update the salary.
Code:
20 | P a g e
• Output:
|Page
21
Program –
15
Write a program to append new records in a binary file
‘STUDENT.dat’. The record can have Rollno, Name and marks.
Code:
22 | P a g e
Program –
16
Write a program to create a CSV file student.csv and store
admission number, name and age of students.
Code:
• Output:
23 | P a g e
Program –
17
Create a CSV file by entering user id and password, read and
search the password for given user id.
Code:
24 | P a g e
Program –
18
Write a program to implement a stack for these book details (book
no, book name). That is now each item node of the stack contains two
25 | P a g e
Program –
types of information-a book no. and its name. Just implement PUSH
& DISPLAY operations.
Code:
26 | P a g e
• Output:
27 | P a g e
Program – 19
Write a program to implement all stack operations (push,
pop, peek& display) using a list data structure.
Code:
28 | P a g e
29 | P a g e
30 | P a g e
• Output:
31 | P a g e
MySQL
Connectivity
Program – 20
Write the sql commands for i) to v) & find the outputs of the
SQL queries (vi) to (viii) based on the relations Teacher and
Posting given below:
32 | P a g e
i. To show all information about the teacher of History department.
Ans) SELECT * FROM TEACHER WHERE DEPARTMENT = ‘HISTORY’;
iii. To list the names of all teachers with their date of joining in
ascending order.
Ans) SELECT NAME, DATE_OF_JOIN FROM TEACHERS ORDER BY
DATE_OF_JOIN;
iv. To display teacher’s name, salary, age for male teachers only.
Ans) SELECT NAME, SALARY, AGE FROM TEACHERS WHERE
GENDER = ‘M’;
Department Count(*)
Computer Sc 1
History 3
Mathematics 1
34 | P a g e
vii. SELECT Max(Date_of_Join), Min(Date_of_Join) FROM Teacher;
Ans)
Max(Date_of_join) Min(Date_of_join)
31/07/2018 24/03/2008
Jugal Computer Sc
Shiv Om Computer Sc
35 | P a g e
Program –
21
Consider the following table STOCK &DEALERS and write sql
commands for questions i) to iv).
Table: STOCK
36 | P a g e
Table: DEALERS
ii. To display Item no and Item name of those items from stock
table whose unit price is more than 10.
Ans) SELECT Itemno, Item FROM STOCK WHERE Unitprice > 10;
iii. To display the details of those items whose dealer code is 102 or
quantity in stock is more than 100
Ans) SELECT * FROM STOCK WHERE DCODE = 102 OR Qty > 100;
37 | P a g e
Program –
22
Table: EMPLOYEE
Table: JOB
38 | P a g e
i. To display employee ids, names of employees, job ids with
corresponding job titles.
Ans) SELECT EMPLOYEEID, NAME, E.JOBID, JOBTITLE FROM EMPLOYEE,
JOB WHERE EMPLOYEE.JOBID = JOB.JOBID
39 | P a g e
Program –
iv. Insert a new row into the table Job. Ans) INSERT INTO JOB
VALUES(107, “Clerk”, 50000)
23
Create a student table in SQL with attributes - sid, sname, class,
section, gender, city & mark. Integrate SQL with Python by importing
the MySQL module. Display the details of all students from the city
Delhi.
Table: Student
40 | P a g e
• Output:
Program – 24
Change the mark of the student whose Sid is 2, update mark as
500. Display the contents of the table after updation using a
Python script.
41 | P a g e
Program –
42 | P a g e
• Output:
43 | P a g e
44 | P a g e
Program – 25
Write a Python-MySQL connectivity code to insert the following
records into a table STUDENT created under the database SCHOOL.
Structure of the table STUDENT
• Output:
45 | P a g e
Program – 26
Write a Python-MySQL connectivity code to delete two rows from the
above (already created) table STUDENT. Integrating SQL with Python:
• Output:
46 | P a g e