GURU AMAR DASS PUBLIC SCHOOL
COMPUTER SCIENCE(083)
Practical File
On
Submitted To: Submitted By:
Mr. Kawaljeet Singh Harshdeep Kaur
Malhi XII-E
8
Acknowledgement
I wish to express my humble gratitude to my
Computer Science teacher, Mr. Kawal Singh Malhi
for his help, advice and guidance in the preparation
of this file.
I am also greatly indebted to our Principal Dr.
Aparana Mehta and school authorities for providing
me with the facilities and requisite laboratory
conditions for making this file.
Lastly I would like to thank my family for their help
and support.
Harshdeeep Kaur
Class: XII-E
Certificate
This is to certify that Harshdeep Kaur of XII-E of
Guru Amar Dass Public school has completed her
project file under the guidance of Mr. Kawal Singh
Malhi. She has taken care and shown sincerity in
completion of this file.
I hereby certify that this file is upto my expectations
and guidance issued by CBSE.
_________________ _________________
Signature of Internal Signature of External
Examiner Examiner
Table of Contents
S.No. Practical Performed Page
No.
#Python programs
1. WAP to search element in list & display 1
frequency.
2. WAP to search an element in list & 2
display its location.
3. WAP to calculate factorial of number 3
4. WAP to pass a string and count how 4
many vowels.
5. WAP to simulate a dice. 5
6. WAP to read text file & display number of 6
vowels ,consonants , uppercase & lowercase
7. WAP to create a binary file with Name 8
and Roll no. & search a given Roll no.
8. WAP to create a CSV file with user id 10
and password.
9. WAP to display ASCII code of a 12
character.
10. WAP to implement 5 string operations. 13
11. WAP to implement Stack operations. 14
12. WAP to return a dictionary with 17
elements of a list as keys and its
occurrences as values.
13. WAP that accepts a string & calculate 18
no. of lowercase & uppercase letters.
14. WAP to input integers & find LCM. 19
15. WAP to calculate simple interest & 20
amount payable over the period of 5
years.
#SQL queries
16. SQL command exercise 1 21
17. SQL command exercise 2 24
18. SQL command exercise 3 27
#Python-SQL Connectivity
19. Program to insert records to Emp table 30
and display records.
20. Program to search an Employee and 32
display its record.
#PYTHON PROGRAMS
PROGRAM 1: Write a program to search an
element in a list & display the frequency of elements
present in list.
Source code:
Output:
1 | Page
PROGRAM 2: WAP to search an element in list &
print the location of that element.
Source code:
Output:
2 | Page
PROGRAM 3: WAP to calculate factorial of entered
number.
Source code:
Output:
3 | Page
PROGRAM 4: WAP to pass a string to a function &
count how many vowels are present.
Source code:
Output:
4 | Page
PROGRAM 5: WAP to generate random number
between 1 to 6 to simulate a dice.
Source code:
Output:
5 | Page
PROGRAM 6: WAP to read a text file & display the
number of vowels, consonants, upper case & lower
case characters in a file.
Text file:
6 | Page
Source code:
Output:
7 | Page
PROGRAM 7: Create a binary file with Name and
Roll number. Search for a given Roll number & display
the name. If not found, display appropriate message.
Source code:
8 | Page
Output:
9 | Page
PROGRAM 8: WAP to create a CSV file by entering
user-id & password.
Source code:
10 | P a g e
Output:
11 | P a g e
PROGRAM 9: WAP to display ASCII code of a
character.
Source code:
Output:
12 | P a g e
PROGRAM 10: WAP to implement 5 python string
operations.
Source code:
Output:
13 | P a g e
PROGRAM 11: WAP to implement Stack operations.
Source code:
14 | P a g e
15 | P a g e
Output:
16 | P a g e
PROGRAM 12: WAP to return a dictionary with
elements of a list as keys & frequency of its
occurrences as value.
Source code:
Output:
17 | P a g e
PROGRAM 13: WAP that accepts a string &
calculates the number of uppercase and lowercase
letters.
Source code:
Output:
18 | P a g e
PROGRAM 14: WAP to input two integers and find
their LCM.
Source code:
Output:
19 | P a g e
PROGRAM 15: WAP to calculate simple interest &
amount payable by inputting principal amount and
rate from use for a period of 5 years.
Source code:
Output:
20 | P a g e
#SQL Queries
1.Write a SQL command to create a database named
‘School’. Also write command to create a Student
table with Student id, name & marks as attributes
where Student id is the primary key. Also perform the
following queries:
• Add columns ‘Mobile’ & ‘Sex’.
• Add column ‘Address’.
• Change name of column ‘Sex’ to ‘Gender’.
• Delete a column ‘Address’.
21 | P a g e
✓ Add columns ‘Mobile’ & ‘Sex’ in the table Student
✓ Add column ‘Address’.
22 | P a g e
✓ Change name of column ‘Sex’ to ‘Gender’.
✓ Delete a column ‘Address’.
23 | P a g e
2. Create a table named Student. Add columns
Student id, Name, Address, Mobile, DOB & Fee. Also
perform following queries:
• Insert some data into the table Student.
• Show the table Student.
• Show details of students with fee more than
12600.
• Show details of students with fee less than
12600.
24 | P a g e
✓ Insert data in Student.
✓ Show table.
25 | P a g e
✓ Show details of students with fee more than
12600.
✓ Show details of students with fee less than 12600.
26 | P a g e
3. Create a table ‘student’ with the following fields:
Student id, name & marks. Perform following queries:
• Insert records.
• Find the maximum, minimum and average of
marks.
• Sort in descending order with accordance to
marks.
• Delete the record of the student with student id
as 5.
27 | P a g e
✓ Insert records
✓ Find max, min & avg of marks.
28 | P a g e
✓ Sort in descending order according to marks.
✓ Delete the record of student with student id as 5.
29 | P a g e
#Python-SQL Connectivity
1.Create a Python SQL connectivity program to insert
records to Emp table and display the records.
Source code:
Python output:
30 | P a g e
MySQL output:
31 | P a g e
2. Write a python program to search an Employee
using EMPID and display the record if present, if not
then display the appropriate message.
Source code:
Output:
• Python output:
32 | P a g e
• MySQL output:
• Python output:
• MySQL output:
33 | P a g e