Practical File
Practical File
COMPUTER SCIENCE(083)
Practical File
On
Harshdeeep Kaur
Class: XII-E
Certificate
_________________ _________________
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
#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
22 | P a g e
✓ Change name of column ‘Sex’ to ‘Gender’.
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.
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
28 | P a g e
✓ Sort in descending order according to marks.
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