PM SHRI Kendriya Vidyalaya
Janakpuri
New Delhi - 110058
SESSION: 2025-2026
PRACTICAL FILE FOR
INFORMATICS PRACTICES
NAME: AYAAN
RollNo:
Class: XII-C (Commerce)
Subject: Informatics Practices
Subject code: 065
Practical Guide: Ranjeet Prasad PGT(CS)
[Link] PRACTICAL DATE [Link] SIGNATURE
INPUT:-
#practical 01
#using dictionary
import pandas as pd
import numpy as np
obj1=[Link]({"a":46,"b":92,"c":34,"d": [Link],"e":32})
print(obj1)
#using list
import pandas as pd
import numpy as np
obj1=[Link]([46,92,34,[Link],32],index=["a","b","c","d","e"])
print(obj1)
#using ndarray
import pandas as pd
import numpy as np
a=[Link]([46,92,34,[Link],32])
m=[Link](a,index=["a","b","c","d","e"])
print(m)
OUTPUT :-
Date: 29/07/2025
PRACTICAL NO. 2 DATA ACCESS IN SERIES
AIM:- Write a Python Program to create the given series object DF and perform the operations
on the series as per the following:
Index Data
delhi 100
surat 90
mandi 124
palam NaN
puram 120
• Print values at index ‘delhi’ and ‘palam’.
• Change the value 90 at index ‘surat’ to 99.
• Write a slice to extract/fetch values at index delhi, surat and mandi.
• Use the head and tail methods to extract the first 2 and last 2 rows of series.
• Multiply all values in DF by 2 and store in another series object DF2.
• Display all the values which are greater than 40.
• Display the count of all values including NaN values.
• Delete the rows with index ‘mandi’ and ‘puram’.
INPUT:-
#practical 02
import pandas as pd
import numpy as np
DF=[Link]({"Delhi":100,"Surat":90,"Mandi":124,"Palam":[Link],"Pu
ram":120})
print(DF[[0,3]])
DF[1]=99
print(DF)
print(DF[0:3])
print([Link](2))
print([Link](2))
OUTPUT:-
Date: 29/07/2025
PRACTICAL NO. 3 PROPERTIES OF SERIES
AWrite a Python Program to create the given series object obj1 and perform the operations on
obj1 as per the given parts from (i) to (v) :
Index Data
a 46
b 92
c 34
d NaN
e 32
• Find the shape of the series object obj1.
• Find the data type of the data stored in the series object obj1.
• Find the dimension of the series object obj1.
• Find the total number of non-NaN values in obj1.
• Find the total number of bytes taken by series object obj1.
INPUT:-
#practical 03
import pandas as pd
import numpy as np
obj1=[Link]({"A":46,"B":92,"C":34,"D":[Link],"E":32})
print([Link])
print([Link])
print([Link])
print([Link])
print([Link])
OUTPUT:-
Date: 13/07/2025
PRACTICAL NO. 4 OPERATIONS ON SERIES
AIM:-Write a Python Program to create the given series object S1 and perform the operations on
S1 as per the given below parts:
Index Data
Phy 82
Math 40
Eng 78
Acc 90
• Display all index values BST 89
• Change value from index 3 to 4 to 99
• Change index values to [‘P’ , ‘M’ , ‘E’ , ‘A’ , ‘B’]
• Display the complete series data in reverse order
• Add and display series after adding 10 to all data values
INPUT:-
#practical 04
import pandas as pd
S1=[Link]({"PHY":82,"MATHS":40,"ENG":78,"ACC":90,"BST":89})
print(S1)
print([Link])
S1['ACC']=99
S1['BST']=99
print(S1)
[Link]=["P","M","E","A","B"]
print(S1)
print(S1[::-1])
print(S1+10)
OUTPUT:-
Date: 22/07/2025
PRACTICAL NO. 5 – DATAFRAME OPERATIONS
AIM:- Write a Python Program to create the given DataFrame EMPLOYEE using
following methods and display them:
• Using dictionary of list
• Using list of dictionaries
• Using dictionary of series
• Using series
INPUT:-
#practical 05
import pandas as pd
d={"EID":[1,2,3,4,5],"Name":["John","Rin","Shobhit","aditya","rashi"],"department":["it","mkt"
,"it","mkt","admin"],"salary":[50000,45000,55000,60000,52000]}
EMPLOYEE=[Link](d)
print(EMPLOYEE)
import pandas as pd
d=[{'Eid':1,'name':'john','department':'it','salary':50000},{'Eid':2,"name":"rin","department":"mkt
","salary":45000}
,{'Eid':3,'name':'shobhit','department':'it','salary':55000},
{'Eid':4,'name':'aditya','department':'mkt','salary':60000},{'Eid' :5
,'name':'rashi',"department":'admin','salary':52000}]
EMPLOYEE=[Link](d)
print(EMPLOYEE)
import pandas as pd
s1=[Link]([1,2,3,4,5])
s2=[Link](['john','rin','shobhit','aditya','rashi'])
s3=[Link](['it','mkt','it','mkt','admin'])
s4=[Link]([50000,45000,55000,60000,52000])
d={'EID':s1,'name':s2,'department':s3,'salary':s4}
EMPLOYEE=[Link](d)
print(EMPLOYEE)
OUTPUT:-
Date: 22/07/2025
PRACTICAL NO. 6 – DATAFRAME OPERATIONS
AIM: Write a Python Program to create the given DataFrame DF and perform the operation as
given in the parts below:
• Display the Name Column.
• Display Roll and Name without using loc.
• Display Name and Class using loc
• Display only the second row
• Display the first three rows using loc.
• Display Roll and Class columns.
• Display first and last row.
• Print following value from dataframe : Vijay
INPUT:-
#practical 6
import pandas as pd
d={"roll":[1,2,3,4,5],"Name":["abhay","diya","vijay","kamal","john"],
"class":["XI","XII","XI","XII","XI"],"marks":[40,59,96,80,72]}
DF=[Link](d)
print(DF['Name'])
print(DF[["roll","Name"]])
print([Link][:,["class","Name"]])
print([Link][1,:])
print([Link][[0,1,2]])
print(DF[["roll","class"]])
print([Link][[0,4]])
print([Link][2,:'Name'])
print([Link][0:2,'marks'])
OUTPUT:-
Date: 26/07/2025
PRACTICAL NO. 7 – DATAFRAME OPERATIONS
AIM: Write a Python Program to create the given DataFrame MDF and perform the operation
as given in the questions below:
1
• Write statement to perform modification of following values:
• Change Admno 981 to 985.
• Add the following row: 452 , ‘Sujata’ , ‘Kumari’ , ‘XII’
• Delete the row added in part (ii).
• Add a new column ‘Section’ in the dataframe with all its values as ‘A’.
• Delete the column ‘Section’.
INPUT:-
#practical07
import pandas as pd
d=[{'Admn':123,'first name':'sumit','last name':'roy','class':"XI"},{'Admn':514,'first
name':'nidhi','last name':'singh','class':"XII"},
{'Admn':981,'first name':'reena','last name':'kumari','class':"XI"},{'Admn':265,'first
name':'ravi','last name':'kumar','class':"XI"},
{'Admn':225,'first name':'sanjay','last name':'das','class':"XII"},{'Admn':122,'first
name':'vivek','last name':'kumar','class':"X"}]
mdf=[Link](d)
print(mdf)
[Link][2]=985
print(mdf)
[Link][6]=[452,'sujata','kumari','XII']
print(mdf)
[Link](2,axis=0,inplace=True)
print(mdf)
[Link][:,'section']=['a','b','a','c','b','a']
print(mdf)
[Link]('section',axis=1,inplace=True)
print(mdf)
OUTPUT:-
Date: 26/07/2025
PRACTICAL NO. 8 – DATAFRAME OPERATIONS
AIM: Write a Python Program to create the given DataFrame DF and perform the
operation as given in the parts below:
• Display the first column using iloc.
• Display the first two columns using iloc.
• Display EID and Salary column using iloc.
• Display the first three rows using iloc.
• Display the first and third rows using iloc.
• Change column Ename to Name and Department to Dept
• Change row index 0 to ‘a’ and 1 to ‘b’
INPUT:-
#practical 08
import pandas as pd
d=[{'Eid':1,'name':'john','department':'it','salary':50000},{'Eid':2,"name":
"rin","department":"mkt","salary":45000}
,{'Eid':3,'name':'shobhit','department':'it','salary':55000},
{'Eid':4,'name':'aditya','department':'mkt','salary':60000},{'Eid' :5
,'name':'rashi',"department":'admin','salary':52000}]
df=[Link](d)
print(df)
print([Link][:,0])
print([Link][:,[0,1]])
print([Link][:,[0,3]])
print([Link][[0,1,2]])
print([Link][[0,3]])
print([Link]({"name":"Ename","department":"dept"},axis=1,inplace=
True))
print([Link]({0:"a",1:"b"}))
OUTPUT:-
PRACTICAL NO. 9 – ARITHMETIC OPERATIONS ON
AIM: Write a Python Program to the create the given Dataframes and perform the arithme c
opera on specified in parts from (i) to (vi):
df1 df2
C
A B C A B
0 1 2 3 0 1 2 3
1 4 5 6 1 4 5 6
2 7 8 9
2 7 8 9
A B A B C A
0 8 4 0 10 20 30 0 100
1 2 6 1 40 50 60 1 400
2 70 80 90 2 500
df3 df4 df5
• Perform addition of df1 and df2
• Perform addition of df1 and df3.
• Perform subtraction of df1 and df3.
• Perform subtraction of df3 and df5.
• Perform multiplication of df3 and df4.
• Perform division of df5 by df3.
INPUT:-
#practical 09
import pandas as pd
a={"a":[1,4,7],"b":[2,5,8],"c":[3,6,9]}
b={"e":[1,4,7],"f":[2,5,8],"g":[3,6,9]}
c={"a":[8,2,6],"b":[4,6,5]}
d={"a":[10,40,70],"b":[20,50,80],"c":[30,60,90]}
e={"a":[100,400,500]}
df1=[Link](a)
df2=[Link](b)
df3=[Link](c)
df4=[Link](d)
df5=[Link](e)
print(df1+df2)
print(df1+df3)
print(df1-df3)
print(df3-df5)
print(df3*df4)
print(df5/df3)
OUTPUT:-
Date: 13/07/2025
PRACTICAL NO. 10 – DATAFRAME PROPERTIES
AIM: Write a Python Program to create the given DataFrame DF and perform the operation as
given in the questions below. Also write the Output.
• Find all the index labels.
• Find all the column labels.
• Find total number of elements in the Dataframe.
• Find the shape of the Dataframe.
• Find the dimension of the Dataframe.
• Find total number of values in each column.
• Find total number of values in each row.
INPUT:-
#practical 10
import pandas as pd
import pandas as pd
d=[{'Admn':123,'first name':'sumit','last
name':'roy','class':"XI"},{'Admn':514,'first name':'nidhi','last
name':'singh','class':"XII"},
{'Admn':981,'first name':'reena','last
name':'kumari','class':"XI"},{'Admn':265,'first name':'ravi','last
name':'kumar','class':"XI"},
{'Admn':225,'first name':'sanjay','last
name':'das','class':"XII"},{'Admn':122,'first name':'vivek','last
name':'kumar','class':"X"}]
DF=[Link](d)
print(DF)
print([Link])
print([Link])
print([Link])
print([Link])
print([Link])
print([Link](0))
print([Link](1))
OUTPUT:-
Date: 13/07/2025
PRACTICAL NO. 11 – ITERATION ON DATAFRAME
AIM: Write a Python Program to create the given DataFrame ndf and perform the
operation as given in the questions below.
2016 2018 2019
Qtr1 400 200 800
Qtr2 356 350 600
Qtr3 220 150 320
Qtr4 650 250 500
• Display column wise data from Dataframe using iteritems( )
• Display row wise data from Dataframe using iterrows( )
• Save this dataframe in a CSV file “ [Link]”
INPUT:-
#practical 11
import pandas as pd
a={2016:[400,356,220,650],
2018:[200,350,150,250],
2019:[800,600,320,500]}
ndf=[Link](a,index=['qtr1','qtr2','qtr3','qtr4'])
print(ndf)
for(c,cv)in [Link]():
print("col label:",c)
print(cv)
print("***********")
ndf.to_csv("[Link]")
print("CSV Saved Suscessfully")
OUTPUT:-
\\\\\\\\\\\\\\
PRACTICAL NO. 12 – PLOTTING LINE CHART
AIM: Write python code to plot the given line chart. Make the color of the line as
‘Red’.Give x-axis label as “values” and y-axis label as “cube of values”. Also give title as
“A simple chart”.
INPUT:-
import [Link] as plt
a=[1,2,3,4] b=[10,20,30,60]
[Link](a,b,"r") [Link]("Values")
[Link]("Cube of values")
plt. tle("Asimplechart"
)
[Link]()
Output:
Date: 19/07/2025
PRACTICAL NO. 13 – PLOTTING BAR CHART
AIM: Write code to plot following bar chart.
So ware used: IDLE (python 3.12 64 bit)
Input:
import
[Link] as
plt a=[1,2,3,4]
b=[5,10,15,20]
[Link](a,b,color=["k","r","b"
"g"])
[Link]()
OUTPUT:-
Date: 21/07/2025
PRACTICAL NO. 14 – PLOTTING BAR
CHART
AIM: Write code to plot following bar chart.
So ware used: IDLE (python 3.12 64 bit)
Input:
import [Link] as plt
a=["yellow","green","orange","blue","whit
e"] b=[20,30,15,20,35]
[Link](a,b,color
=["y","g","r","b",
"w"])
[Link](5,40)
[Link](True)
[Link]("Numb
er of students")
[Link]("Favou
rite colour")
[Link]()
OUTPUT:-
Date:21/07/2025
PRACTICAL NO. 15 – PLOTTING HISTOGRAM
AIM: The heights of 10 students of eighth grade are given below:
Height_cms=[145,141,142,142,143,144,141,140,143,144]
Write suitable Python code to generate a histogram based on the given data, along with an
appropriate chart title and both axis labels. Also give suitable python statement to
save this chart.
Software used:
IDLE (python 3.12
64 bit) Input:
import
[Link] as
plt
a=[145,141,142,143
,144,141,140,143,1
44] [Link](a)
[Link]("Height in
cms")
[Link]("Number
of students")
[Link]("Height of
8th class students")
[Link]("Height.j
pg") [Link]()
Output: