TULSI KIDS SCHOOL BALOTRA
PRACTICAL FILE
ON
INFORMATICS PRACTICES
SEBJECT CODE- 065
SESSION- 2024-25
Submitted By- Submitted To-
NAME: ARHAM SHRI SHRIMAL MR. HEERALAL SUTHAR
ROLL NO. :12A01 (PGT)
CLASS: XII
DECLARATION
I ARHAM SHRI SHRIMAL, bearing roll no 12A01, a student of Class XII TULSI KIDS
SCHOOL BALOTRA here by declare that I own the full responsibility for the information,
results etc. provided in this Practical File. It has been created successfully by using the
Database Tool MySQL and SQL commands at TULSI KIDS SCHOOL BALOTRA in complete
fulfillment of practical (curriculum of Central Board of Secondary Education CBSE of
Informatics Practices(065) conducted by CBSE, New Delhi for the academic session
2024-225.
Roll No: 12A01
Class: XI
TULSI KIDS SCHOOL ,BALOTRA
INTERNAL TEACHER SIGN. EXTERNAL TEACHER SIGN.
PRINCIPAL SIGN.
(TULSI KIDS SCHOOL)
TABLE OF CONTENT
Sr No Topic Page No Remark
1 Overview of Python
2 Overview of MySQL
3 System Requirement and Specifications
4 Data Handling Practicals
5 Practical1
6 Practical2
7 Practical3
8 Practical4
9 Practical5
10 Practical6
11 Practical7
12 Practical8
13 Practical9
14 Practical10
15 Practical 11
16 Practical 12
17 Practical 13
18 Practical 14
19 Practical 15
20 Practical 16
21 Practical 17
22 Practical 18
Sr No Topic Page No Remark
23 Practical19
24 Practical20
25 Practical21
26 Practical22
27 Practical23
28 Practical24
29 Practical25
30 MySQL Practicals
31 Practical26
32 Practical27
33 Practical 28
34 Practical 29
35 Practical 30
36 Practical 31
37 Practical 32
38 Practical 33
39 Practical 34
40 Practical 35
41 Practical 36
42 Practical 37
43 Practical 38
44 Practical 39
45 Practical 40
46 Bibliography
PRATICAL 1
Problem statement: 1. Create a Series object using the python sequence with 5 elements:
Solution:
Source Code:
import pandas as pd
L = [12,23,34,45,56]
S= pd.Series(S)
print(S)
Screenshot:
Output
PRATICAL 2
Problem statement: 1. Create a Series object ‘vowel’ to store all vowels individually. Its
index should be 1,2,3,4 & 5.:
Solution:
Source Code:
import pandas as pd
vowels = pd.Series(['a','e','i','o','u'], index = [1,2,3,4,5]) print(vowels)
Screenshot:
Output
PRATICAL 3
Problem statement: Create s Series object using ndarray that has 5 elements in the range
50 and 100:
Solution:
Source Code:
import pandas as pd
import numpy as np
S = pd.Series(np.arange(50,100,10))
print(S)
Screenshot:
Output
PRATICAL 4
Problem statement: Create a Series object using dictionary to that stores the no of
students in each section of class 12th of your school:
Solution:
Source Code:
import pandas as pd
D = {'A':23,'B':34,'C':36,'D':40,'E':32}
S = pd.Series(D)
print(S)
Screenshot:
Output
PRATICAL 5
Problem statement: Total no of students to be admitted is 350 in Yojna School every year.
Write code to create a Series object ‘School’ that stores these total no of students for the
year 2015 to 2022:
Solution:
Source Code:
import pandas as pd
S = pd.Series(350, range(2016,2023))
print(S)
Screenshot:
Output
PRATICAL 6
Problem statement: Create a Series object ‘Item’ that stores rate of each product as given
below:
Soap 54
Salt 20
Sugar 39
Write code to modify rate of soap to 44 and sugar to 42. print the changed rate:
Solution:
Source Code:
import pandas as pd
S = pd.Series([54,20,39],['soap','salt','sugar'])
print(S)
S['soap']=44
S['sugar']=42
print("After Updating values")
print(S)
Screenshot:
Output
PRATICAL 7
Problem statement: No of students in class 11 and class 12 in three streams (science,
commerce and humanities) are stored in 2 series object class 11 and class 12. write code
to find total no of students in class 11 & class 12 stream wise:
Solution:
Source Code:
import pandas as pd
D1={'Science':32,'Commerce':36,'Humaniti':20}
D2= {'Science':28,'Commerce':34,'Humanities':22}
Class11 = pd.Series(D1)
Class12 = d.Series(D2)
print(Class11)
print(Class12)
print('Total tudents')
print(Class11 + Class12)
Screenshot:
Output
PRATICAL 8
Problem statement: Create a Series object ‘population’ to store population of 5 different
metro cities and display the population that are more than 300000:
Solution:
Source Code:
import pandas as pd
population = pd.Series([400000, 25400, 301100, 100500,505000],
['Mumbai','Kolkata','Delhi','Chennai','Bangluru'])
print(population)
print('Poplulation more than 300000')
print(population[population>300000])
Screenshot:
Output
PRATICAL 9
Problem statement: Create a series ‘temp’ that stores temperature of seven days in it. Its
index should be ‘Sunday’, ‘Monday’ ….
Write script to
1. Display temp of first 3 days.
2. Display temp of last 3 days.
3. Display all temp in reverse order like Saturday, Friday,….
4. Display temp from Tuesday to Friday.
5. Display square of all temperature.:
Solution:
Source Code:
import pandas as pd
temp = pd.Series(
[45,42,40,46,39,38,40],
['Sunday','Monday','Tuesday','wednesday','Thursday','Friday','Saturday']
)
print(temp)
print("Temp of first three days\n",temp.head(3))
print("Temp of last three days\n",temp.tail(3))
print("Temp in reverse order\n", temp[::-1])
print("Temp from Tuesday to Friday\n",temp['Tuesday':'Friday'])
print("Square of all Temprature\n",temp*temp)
Screenshot:
Output
PRATICAL 10
Problem statement: Create a Series object ‘employee’ that stores salary of 7 employees.
Write script to print
1. Total no of elements
2. Series is empty or not
3. Series consist NaN value or not
4. Count Non-NA elements
5. Axis labels:
Solution:
Source Code:
import pandas as pd
D ={'ram':34000,'hari':42000,'suman':30000,'chandan':45000,'raghu':23000}
employee = pd.Series(D)
print(employee)
print("Total no of Employees",employee.size)
if employee.empty:
print("Series is empty")
else:
print("Series is not empty")
if employee.hasnans:
print("Series contains NaN elements")
else:
print("Series does not contains NaN elements")
print("Total no of Non NA elements ",employee.count())
print("Axis labels\n", employee.axes)
Screenshot:
Output
PRATICAL 11
Problem statement: Create the following dataframe ‘Sport’ containing sport wise marks for
five students. Use 2D dictionary to create dataframe.
Student Sport Marks
I Jai Cricket 80
II Raj Football 76
III John Tennis 89
IV Karan Kabaddi 92
V Chandu Hockey 97
Solution:
Source Code:
import pandas as pd
D = {'student':['jai','raj','john','karan','chandu'],
'sport':['cricket','football','tennis','kabaddi','hockey'],
'marks':[80,76,89,92,97]
}
sport = pd.DataFrame(D, ['I','II','III','IV','V'])
print(sport)
Screenshot:
Output
PRATICAL 12
Problem statement: Create a dataframe from list containing dictionaries of most
economical bike with its name and rate of three companies. Company name should be the
row labels.
Solution:
Source Code:
import pandas as pd
L1 = {'Name':'Sports','Cost':60000}
L2 = {'Name':'Discover','Cost':62000}
L3 = {'Name':'splendor','Cost':63000}
Bike = [L1,L2,L3]
df = pd.DataFrame(Bike, ['TVS','Bajaj','Hero'])
print(df)
Screenshot:
Output
PRATICAL 13
Problem statement: Consider two series object staff and salaries that stores the number of
people in various office branches and salaries distributed in these branches respectively.
Write a program to create another Series object that stores average salary per branch and
then create a dataframe object from these Series object.
After creating dataframe rename all row labels with Branch name.
Solution:
Source Code:
import pandas as pd
staff = pd.Series([20,24,30,18])
salary = pd.Series([240000,336000,450000,270000])
avg = salary/staff
org = {'Employees':staff,'Amount':salary,'Average':avg}
df = pd.DataFrame(org)
print("Without Row Label")
print(df)
df.index = ['sale','store','marketing','maintenence']
print("With Row Label")
print(df)
Screenshot:
Output
PRATICAL 14
Problem statement: Create the following dataframe ‘sales’ containing year wise sales
figure for five sales persons in INR. Use the year as column labels, and sales person names
as row labels.
2014 2015 2016 2017
Madhu 1000 2000 2400 2800
Kusum 1500 1800 5000 6000
Kinshuk 2000 2200 7000 7000
Ankit 3000 3000 1000 8000
Shruti 4000 4500 1250 9000
Write program to do the followings
1. Display row labels of ‘sales’
2. Display column label of ‘sales’
3. Display last two rows of the ‘sales’
4. Display first two rows of the ‘sales’.
Solution:
Source Code:
import pandas as pd
D = {2014:[1000,1500,2000,3000,4000],2015:[2000,1800,2200,3000,4500],
2016:[2400,5000,7000,1000,1250],2017:[2800,6000,7000,8000,9000]}
sale = pd.DataFrame(D,['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
print("----DataFrame-----")
print(sale)
print("----Row Labels--------------")
print(sale.index)
print("----Column Labels---------------")
print(sale.columns)
print("----Bottom two Rows--------------")
print(sale.tail(2))
print("----Top two Rows-------------")
print(sale.head(2))
Screenshot:
Output
PRATICAL 15
Problem statement: Create a dataframe ‘sales2’ using dictionary as given below and write a
program to append ‘sales2’ to the dataframe ‘sales’ created in previous practical 14.
2018
Madhu 1600
Kusum 1100
Kinshuk 5000
Ankit 3400
Shruti 9000
Solution:
Source Code:
import pandas as pd
D = {2014:[1000,1500,2000,3000,4000],2015:[2000,1800,2200,3000,4500],
2016:[2400,5000,7000,1000,1250],2017:[2800,6000,7000,8000,9000]}
sale = pd.DataFrame(D,['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
print("----DataFrame ")
print(sale)
sale2=
pd.DataFrame({2018:[1600,1100,5000,5400,9000]},['Madhu','Kusum','Kinshuk
','Ankit','Shruti'])
print(sale2)
sale = sale.join(sale2)
print(sale)
Screenshot:
Output
PRATICAL 16
Problem statement: Create a dataframe ‘cloth’ as given below and write program to do
followings:
Check ‘cloth’ is empty or not
Change ‘cloth’ such that it becomes its transpose
Display no of rows and columns of ‘cloth’
Count and display Non NA values for each column
Count and display Non NA values for each row
CName Size Price
C1 Jeans L 1200
C2 Jeans XL 1350
C3 Shirt XL 900
C4 Trouser L 1000
C5 T-Shirt XL 600
Solution:
Source Code:
import pandas as pd
D = {'CName':['Jeans','Jeans','Shirt','Trouser','T-Shirt'],
'Size':['L','XL','XL','L','XL'], 'Price':[1200,1350,900,1000,600]}
cloth = pd.DataFrame(D) print("----Dataframe ")
print(cloth)
print("----checking dataframe is empty or not ")
if cloth.empty:
print("Cloth is Empty")
else:
print("Cloth is not Empty")
print("----Transpose Dataframe ")
print(cloth.T)
print("----Total no of rows and columns ")
print(cloth.shape)
print("----No of Non NA elements in each column ")
print(cloth.count())
print("----No of Non NA elements in each row ")
print(cloth.count(1))
Screenshot:
Output
PRATICAL 17
Problem statement: Create a dataframe ‘cloth’ as given below and write program to do
followings:
Change the name of ‘Trouser’ to ‘pant’ and Jeans to ‘Denim’
Increase price of all cloth by 10%
Rename all the indexes to [C001, C002, C003, C004, C005]
Delete the data of C3 (C003) from the ‘cloth’
Delete size from ‘cloth’
CName Size Price
C1 Jeans L 1200
C2 Jeans XL 1350
C3 Shirt XL 900
C4 Trouser L 1000
C5 T-Shirt XL 600
Solution:
Source Code:
import pandas as pd
D = {'CName':['Jeans','Jeans','Shirt','Trouser','T-Shirt'],
'Size':['L','XL','XL','L','XL'], 'Price':[1200,1350,900,1000,600]}
cloth = pd.DataFrame(D,['C1','C2','C3','C4','C5'])
print("----Dataframe")
print(cloth)
print("----Change name of Trouser to Pant ")
cloth.at['C4','CName']='Pant'
#cloth.CName['C4']='Pant'
#cloth.loc['C4','CName']='Pant' print(cloth)
print("----Increase price of all cloth by 10% ")
cloth['Price'] = cloth['Price'] + cloth['Price']*10/100
print(cloth)
print("----Rename all the indexes to [C001,C002,C003,C004,C005] ")
cloth.rename(index = {'C1':'C001','C2':'C002','C3':'C003','C4':'C004','C5':'C005'},inplace = 'True')
print(cloth)
print("----Delete the data of C003 ")
cloth = cloth.drop(['C003'])
print(cloth)
print("----Delete column 'Size' ")
del cloth['Size']
print(cloth)
Screenshot:
Output
PRATICAL 18
Problem statement: Create a dataframe ‘aid’ as given below and write program to do
followings:
1. Display the books and shoes only
2. Display toys only
3. Display quantity in MP and CG for toys and books.
4. Display quantity of books in AP
Toys Books Shoes
MP 7000 4300 6000
UP 3400 3200 1200
AP 7800 5600 3280
CG 4100 2000 3000
Solution:
Source Code:
import pandas as pd
D = {'Toys':{'MP':7000,'UP':3400,'AP':7800,'CG':4100},
'Books':{'MP':4300,'UP':3200,'AP':5600,'CG':2000},
'Shoes':{'MP':6000,'UP':1200,'AP':3280,'CG':3000},}
aid = pd.DataFrame(D)
print('----DataFrame-------------')
print(aid)
print('----Display the books and shoes only-----------------------')
print(aid.loc[:,['Books','Shoes']])
print('----Display toys only-------------------')
print(aid['Toys'])
print('----Display quantity in MP and CG for toys and books----------------------------')
print(aid.loc[['MP','CG'],['Toys','Books']])
print('----Display quantity of books in AP------------------------')
print(aid.at['AP','Books'])
Screenshot:
Output
PRATICAL 19
Problem statement: Create a dataframe ‘aid’ as given below and write program to write
the values of ‘aid’ to a comma separated file ‘aidfigures.csv’ on the disk. Do not write the
row labels and column labels.
Toys Books Shoes
MP 7000 4300 6000
UP 3400 3200 1200
AP 7800 5600 3280
CG 4100 2000 3000
Solution:
Source Code:
import pandas as pd
D = {'Toys':{'MP':7000,'UP':3400,'AP':7800,'CG':4100},
'Books':{'MP':4300,'UP':3200,'AP':5600,'CG':2000},
'Shoes':{'MP':6000,'UP':1200,'AP':3280,'CG':3000},}
aid = pd.DataFrame(D)
print(aid)
aid.to_csv(path_or_buf = 'C:/sample/aidfigures.csv', header = False, index = False)
Screenshot:
Output
PRATICAL 20
Problem statement: Read the data in the file ‘aidfigure.csv’ into a dataframe ‘aidretrieved’
and display it. Now update the row labels and column labels of ‘aidretrieved’ to be the
same as that of ‘aid’ of practical 19.
Toys Books Shoes
MP 7000 4300 6000
UP 3400 3200 1200
AP 7800 5600 3280
CG 4100 2000 3000
Solution:
Source Code:
import pandas as pd
aidretrieved = pd.read_csv('C:/sample/aidfigures.csv',
names=['Toys','Books','Shoes'],)
aidretrieved.index = ['MP','UP','AP','CG'] print(aidretrieved)
Screenshot:
Output
PRATICAL 21
Problem statement: Collect and store total medals won by 10 countries in Olympic games
and represent it in form of bar chart with title to compare an analyze data.
Solution:
Source Code:
import matplotlib.pyplot as plt
medals = [213,224,300,59,100,140,256,98,60,24]
country = ['Ger','Itly','USA','Jamca','Japan',
'India','China','Aus','Arg','Ethopia']
plt.bar(country, medals)
plt.title('Olympics Medal Tally')
plt.show()Screenshot:
Output
PRATICAL 22
Problem statement: Techtipnow Automobiles is authorized dealer of different Bikes
companies. They record the entire sale of bikes month wise as give below:
Jan Feb Mar Apr May Jun
Honda 23 45 109 87 95 100
Suzuki 45 57 75 60 50 30
Tvs 97 80 84 68 80 108
To get proper analysis of sale performance create multiple line chart on a common plot
where all bike sale data are plotted.
Display appropriate x and y axis labels, legend and chart title.
Solution:
Source Code:
import matplotlib.pyplot as plt
month = ['jan','feb','mar','apr','may', 'jun']
honda = [23,45,109,87,95,100]
suzuki = [45,57,75,60,50,30]
tvs = [97,80,84,68,80,108]
plt.plot(month,honda, label = 'honda')
plt.plot(month,suzuki, label = 'suzuki')
plt.plot(month,tvs, label = 'tvs')
plt.title('Techtipnow Automobiles Sale Analysis')
plt.xlabel('Month')
plt.ylabel('No of Bikes')
plt.legend(loc = 'lower center')
plt.show()
Screenshot:
Output
PRATICAL 23
Problem statement: Given the school result data, analyses the performance of the
student on different parameters, e.g. subject wise or class wise. Create a dataframe for
the above, plot appropriate chart with title and legend.
Eng Math Phy Chm IT
9 78 89 69 92 96
10 89 91 84 90 98
11 90 80 76 82 90
12 94 98 90 96 100
Solution:
Source Code:
import pandas as pd
import matplotlib.pyplot as plt
d = {'eng':[78,89,90,94],'math':[89,91,80,98],
'phy':[69,84,76,90],'chm':[92,90,82,96], 'IT':[96,98,90,100]}
df = pd.DataFrame(d,[9,10,11,12])
print(df)
df.plot(kind = 'bar',title = 'Class Wise Marks Analysis', xlabel = 'Class', ylabel = 'Marks')
df1 = df.T
df1.plot(kind = 'bar',title = 'Subject Wise Marks Analysis', xlabel = 'Class', ylabel = 'Marks')
plt.legend(loc = 'lower center')
plt.show()
Screenshot:
Output
PRATICAL 24
Problem statement: The following seat bookings are the daily records of a month
December from PVR cinemas:
124,124,135,156,128,189,200,150,158, 150,200,124,143,142,130,130, 170,
189,200,130, 142,167,180,143,143, 135,156,150,200,189,189,142
Construct a histogram from above data with 10 bin..
Solution:
Source Code:
import pandas as pd
import matplotlib.pyplot as plt
L = [124,124,135,156,128,189,200,150,158,
150,200,124,143,142,130,130, 170,
189,200,130, 142,167,180,143,143,
135,156,150,200,189,189,142]
plt.hist(L)
plt.title("Booking Records @ PVR")
plt.show()
Screenshot:
Output
Problem statement: Take data ofPRATICAL
your interest from an 24 open source (e.g. data.gove.in),
aggregate and summarize it. Then plot it using different plotting functions of the Matplotlib
library.
Solution:
Source Code:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('c:\sample\Crime_data.csv')
print(df)
plt.bar(df.Crime,df.Boys,width = 0.25)
plt.bar(0.25,df.Girls,width = 0.25)
plt.bar(0.5,df.Transgender,width = 0.25)
df.plot(kind = 'bar', x = 'Crime')
df.plot(kind = 'bar', x= 'Crime', y= ['Boys','Girls', 'Transgender'])
plt.show()
Screenshot:
Output