You are on page 1of 50

COMPUTER SCIENCE

(Code-083)
PRACTICAL FILE

Name: Mimansha Pandit


Class: XII A
Submitted to: Ms. Manisha Singh
Page 1
COMPUTER
SCIENCE
PRACTICAL FILE
Certificate
This is to certify that Mimansha Pandit of class XII A has completed Computer

Science (Code-083) practical file under my supervision and guidance as per the

latest curriculum of Central Board of Secondary Education (2021-2022).

___________________________ ___________________________

Examiner’s Signature Principal’s Signature

_________________

Teacher In-charge Institution Rubber Stamp

Page 2
Acknowledgement

In the accomplishment of this practical file successfully, many people have best

owned upon me their blessings and the heart pledged support, this time I am

utilizing to thank all the people who have been concerned with this practical file.

Primarily I would thank God for being able to complete practical with success.

Then I would like to thank my Director Principal Dr. Priyanka Mehta and

Informatics Practices teacher Ms. Manisha Singh, whose valuable guidance has

been the ones that helped me prepare this file and make it a success. Their

suggestions and instructions have served as the major contributor towards the

completion of the file. Then I would like to thank my parents and friends who have

helped me with their valuable suggestions and guidance has been very helpful in

various phases. Last but not the least I would like to thank my classmates who

have helped me a lot.

Page 3
Index
S.NO. Title Page number REMARKS

1. Practical 1

2. Practical 2

3. Practical 3

4. Practical 4

5. Practical 5

Page 4
Practical 1 :
Consider the following table FITNESS with details about fitness products being
sold in store. Write the SQL commands to perform the following operations:

Pcode PName Price Manufacturer

P1 TreadMill 21000 Coscure

P2 Bike 20000 Aone

P3 Cross Trainer 14000 Reliable

P4 Multi Gym 34000 Coscore

P5 Massage Chair 5500 Regrosene

P6 Belly Vibrator Belt 6500 Ambawaya

a) Create the table ‘Fitness’.

b) Show the structure of the Table.

Page 5
c) Insert the given values in table Fitness.

d) Display the names of all the products with price more than 20000.

e) Display names of all the products by the manufacturer ‘Aone’.

Page 6
Practical 2 :
Consider the following table FITNESS with details about fitness products being
sold in store. Write the SQL commands to perform the following operations:

Pcode PName Price Manufacturer

P1 TreadMill 21000 Coscure

P2 Bike 20000 Aone

P3 Cross Trainer 14000 Reliable

P4 Multi Gym 34000 Coscore

P5 Massage Chair 5500 Regrosene

P6 Belly Vibrator Belt 6500 Ambawaya

Page 7
a) Change the price of all the products by applying 25% discount reduction.

b) Add a new row for a product with the details: ‘P7, Vibro Exerciser, 2800, Aone’.

c) Display the record where item is manufactured by ‘Coscore’ and Price is more
than 20000.

Page 8
d) Display only the unique names of the manufacturer.

e) Display all the records where ‘PName’ is reflected as ‘ProductName’.

Page 9
Practical 3 :
Consider the following table FITNESS with details about fitness products being
sold in store. Write the SQL commands to perform the following operations:

Pcode PName Price Manufacturer

P1 TreadMill 21000 Coscure

P2 Bike 20000 Aone

P3 Cross Trainer 14000 Reliable

P4 Multi Gym 34000 Coscore

P5 Massage Chair 5500 Regrosene

P6 Belly Vibrator Belt 6500 Ambawaya

a) Display those records where Product Name is Multi Gym, Bike or Massage
Chair.

b) Display only those records where Product Name is NOT Multi Gym, Bike or
Massage Chair.

Page 10
c) Display only those records where Product Name starts with B.

d) Display only those records where Product Name ends with R.

e) Display those records where the second character of manufacturer's name has 'e'.

Page 11
f) Display the Product Name of those records where Price is NULL.

Page 12
Practical 4:
Create the table ‘Gym’ having four fields ‘ICode’, ‘IName’, ‘Price’ and
‘BrandName’ with the following constraints:

ICode IName Price BrandName

G101 Power Fit Exerciser 20000 Power Gymea

G102 Aqua Hand Grip 1800 Reliable

G103 Cycle Bike 14000 Ecobike

G104 Protoner Extreme Gym 30000 Coscore

G105 Massage Belt 500 Message Expert

G106 Cross Trainer 13000 GTC Fitness

a) Apply ‘NOT NULL’ constraint on ‘Price’ field.

b) Apply the ‘Default’ constraint on ‘Price’ as 0.

c) Apply ‘Unique’ constraint on ‘ICode’.

Page 13
d) Apply ‘Check’ constraint at ‘Price’ such that price cannot be less than 5000.

e) Apply primary key on the field ‘ICode’.

f) Create tables ‘Customer’ and ‘Orders’ as shown in the figure and also add the
constraints primary key and foreign key as specified in the figure.
Column Constrain Column Constrain
Name t Name t

SID Primary Order_ID Primary


key key

Last_Nam Order_Date
e

First_Nam Customer_SI Foreign


e D key

Page 14
Amount

Page 15
Practical 5:
Create a table Employee where columns are ‘EmployeeCode’, ‘EmployeeName’, ‘GrossSalary’
and ‘NetSalary’. Ensure that the net salary is less than gross salary.

Page 16
Practical 6:
Consider the table gym and perform the following operations:

ICode IName Price Brandname

G101 Power Fit Exerciser 20000 Power Gymea

G102 Aqua Hand Grip 1800 Reliable

G103 Cycle Bike 14000 Ecobike

G104 Protoner Extreme Gym 30000 Coscore

G105 Massage Belt 500 Message Expert

G106 Cross Trainer 13000 GTC Fitness

a) Add a column ‘Discount’ to the table ‘Gym’.

Page 17
b) Add the primary key constraint to the column ‘ICode’.

c) Change the size of ‘IName’ field from 25 to 30.

Page 18
Practical 7:
Consider the table Empl and write SQL query to perform the following operations:

a) Show the AVG salary for all departments with more than 3 people for a job.

Page 19
b) Display only jobs with maximum salary greater than or equal to 3000.

c) Find out the number of employees working as “Manager”.

d) List the count of employees department wise.

Page 20
e) List the sum of employees’ salaries department wise.

f) List the maximum salary of employees department wise

Page 21
Practical 8:

Page 22
Integrate SQL with Python by importing the MySQL module and display the data of the
“Student” table in a Python program.

Code:

Output:

Practical 9:

Page 23
Integrate SQL with Python by importing the MySQL module and display the information of the
Employee record from the “Employee” table in a Python program.

a) Search Employee number in table to display record and display appropriate message if
not found.

b)Update the employee record for the entered employee number. Delete record of a particular
employee.

Page 24
c)Add a new employee and display the data.

Page 25
Page 26
Python Practical Programs
Q 1) Write a Python program to print unique values from a list.

Q 2Write a Python program to check if a given key already exists in a dictionary.

Page 27
Q 3Write a Python program to print a dictionary where the keys are numbers between 1 and 15
(Both included) and values are square of keys. Example: - {1:1,2:4,3:9,4:16,5:25,6:36,7:49}

Page 28
Q 4Write a python program to remove duplicate characters of a given string.

Page 29
Q 5Write a program to accept values from a user in a tuple. Add a tuple to it and display its
elements one by one. Also display its maximum and minimum value.

Page 30
Q 6Write a program to combine two dictionary adding values for common keys. Example:-d1=
{ ‘a’:100, ‘b’:200, ‘c’:300}d2= {‘a’: 300, ‘b’: 200,‘d’:400}

Page 31
Q 7Write a Python program to swap the contents of a list with the next value divisible by 5.
Example:Input list=[3,25,13,6,35,8,14,45]Output list =[25,3,13,35,6,8,45,14]

Page 32
Q 8Write a python function to calculate the factorial of a number (a non-negative integer). The
function accepts the number whose factorial is to be calculated as the argument.

Page 33
Q 9Write a python function that checks whether a String is palindrome or not.

Page 34
Q 10Write a function in python to find and display the prime numbers from 2 to N. The value of
N should be passed as an argument to the function.

Page 35
Q 11Write a function EvenSum(numbers) to add those values in the tuple of numbers which are
even.

Page 36
Page 37
Q 12Write a function countnow(places) to find and display those place names in which there
are more than five characters after storing the name of places in a dictionary. Example: Places=
{1:”Delhi”,2:”London”, 3:”Paris”, 4:”NewYork”,5:”Dubai”} Output to be displayed: LondonNew
York

Page 38
Q 13Write a program to calculate the following using modules.
a)Energy =m*g*h
b)Distance=ut+1/2at2
c)speed=distance/time

Q 14Write a Python program to read a text file line by line and display each word separated by
a #.

Page 39
Page 40
Q 15Write a Python program to read a text file and display the number
ofvowels/consonants/uppercase/lowercase characters in the file.

Page 41
Q 16Write a function in python to count the number of lines from a text file "story.txt" which is
not starting with an alphabet "T".
Example: If the file "story.txt" contains the following lines:
A boy is playing there. There is a play ground. An aeroplane is in the sky. The sky is pink.
Alphabets and numbers are allowed in the password. The function should display the output as
3

Page 42
Q 17Write a function in Python to remove all the lines that contain the character 'a' in a file and
write it to another file

Page 43
.Q 18Write a function in Python to create a binary file with name and roll number. Search for a
givenroll number and display the name, if not found display appropriate message

Page 44
.Q 19Given a pickled file employee.dat, created using dictionary object having keys: (empcode,
name, and salary)
1.Write a python function that add one more record at the end of file
2.Write a python function that display all employee records whose salary is more than 30000

Page 45
.

Page 46
Q20Write a Python program to create a binary file with roll number, name and marks. Input a
roll number and update the marks.

Page 47
Q 21Write a random number generator that generates random numbers between 1 and 6
(simulates a dice)

Page 48
Q 22Create a CSV file by entering user-id and password, read and sea

Page 49
Page 50

You might also like