0% found this document useful (0 votes)
4 views46 pages

Cp. Muzzamil Practical

The document is a practical record for Computer Science students at Al Alia International Indian School, detailing various programming tasks and SQL commands completed by a student named Mohammed Muzzamil in class XII-A for the academic year 2023-24. It includes a laboratory certificate, an index of programs, and sample code for each task, covering topics such as Python programming, file handling, and SQL database operations. The record serves as a fulfillment of the curriculum requirements set by the Central Board of Secondary Education (CBSE).
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 views46 pages

Cp. Muzzamil Practical

The document is a practical record for Computer Science students at Al Alia International Indian School, detailing various programming tasks and SQL commands completed by a student named Mohammed Muzzamil in class XII-A for the academic year 2023-24. It includes a laboratory certificate, an index of programs, and sample code for each task, covering topics such as Python programming, file handling, and SQL database operations. The record serves as a fulfillment of the curriculum requirements set by the Central Board of Secondary Education (CBSE).
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

AL ALIA INTERNATIONAL INDIAN SCHOOL MALAZ,

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
.

Signature of the External Examiner Signature of the Teacher-In-


Charge Date:

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.

10. Write a python program to read and


displays file content line by line with each
word separated by # symbol.
11. Write a program that reads a text file and
then creates a new file where each
character's case is inverted.
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.
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.
14. Write a program to create a binary file
EMPLOYEE.dat with empno, ename and
salary. Input an employee number and
update the salary.
15. Write a program to append new records in a
binary file ‘STUDENT.dat’. The record can
have Rollno, Name and marks.
16. Write a program to create a CSV file
student.csv and store admission number,
name and age of students.

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:

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
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.

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 –

Write a program to read lines from a text file and display


those lines which start with alphabet ’H’. Code:

• 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

Write a python program to read and displays file content line


by line with each word separated by # symbol.

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’;

ii. To list the names of female teachers who are in Mathematics


department.
33 | P a g e
Ans) SELECT NAME FROM TEACHERS WHERE GENDER = ‘F’;

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’;

v. To display name, bonus for each teacher where bonus is 10% of


salary.
Ans) SELECT NAME, SALARY + (SALARY *10)/100 FROM TEACHER;

vi. SELECT Department, count (*) FROM Teacher GROUP BY


Department;
Ans)

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

viii. SELECT Teacher.name,Teacher.Department, Posting.Place FROM


Teachr, Posting WHERE Teacher.Department = Posting.Department
AND Posting.Place=”Delhi;
Ans)

Name Department Place

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

i. To display the details of all items in the stock table in ascending


order of StockDate.
Ans) SELECT * FROM STOCK ORDER BY StockDate;

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;

iv. To display maximum unit price of items for each dealer


individually as per Dcode from stock table.
Ans) SELECT MAX(Unitprice), Dname FROM STOCK, DEALERS
WHERE STOCK.DCODE = DEALERS.DCODE;

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

ii. To display names of employees, sales and corresponding job


titles who have achieved sales more than 1300000.
Ans) SELECT NAME, SALES, JOBTITLE FROM EMPLOYEE, JOB WHERE
EMPLOYEE.JOBID = JOB.JOBIDAND SALES > 1300000;

iii. To display names and corresponding job titles of those


employees who have “singh” anywhere in their names.
Ans) SELECT NAME, JOBTITLE FROM EMPLOYEE, JOB WHERE
EMPLOYEE.JOBID = JOB.JOBID AND NAME LIKE “%SINGH”;

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

Integrating SQL with Python:

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.

Table Student12 before updating:

41 | P a g e
Program –

Integrating SQL with Python:

42 | P a g e
• Output:

Table Student12 after updating:

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

Integrating SQL with Python:

• 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

You might also like