Swastika
Swastika
OF
INFORMATICS PRACTICES
XII-
Commerce
Session: 2025-2026
Submitted to:
Submitted by: Swastika Bokil
1
CERTIFICATE
of class
Date:
Registration No:
__________________ ______________
Mr. A.S.R Satapathy Mrs. Gargi
Banerjee
(PGT. Informatics Practices) (Principal)
2
_____________
(External)
ACKNOWLEDGEMENT
3
Thanking you,
INDEX
SR. PAGE
NO PARTICULARS NO SIGN
Python Pandas
1. Write python code to create a series object temp2 storing
temperatures of seven days of week. Its indexes should
be ’Sunday’, ‘Monday’,…..’Saturday’.
2. A series object (say T1) stores the average temperature
recorded on each day of month. Write code to display the
temperatures recoded on:(I)first 7 days (ii)last 7 days
4
zonal offices. Zone name should be in a row lables
10. consider two series object staff and salaries that store the
number of people in various office branches and salaries
distribted in these brances, respectively.
5
stores temperature of seven days in it. take any random
seven temperature.
23. Draw the histogram for population_ages = [22, 55, 62, 45,
21,
22,34,42,42,4,99,102,110,120,121,122,130,111,115,112,8
0,75,65,54,44,43,42,48] and bins = [0, 10, 20, 30, 40, 50,
60, 70, 80, 90, 100, 110,120,130] through python program
with suitable title and label.
24. object1 population stores the details of population in four
metro cities of India and object2 Av income stores the
total average income reported in previous year in each of
these metros. Calculate income per capita for each of
these metro cities.
25. Create and display a data frame from a 2D dictionary,
sales, which stores the quarter-wise sales as
inner dictionary for two years, as shown below:
sales={'yr1':
{'qtr1':34500,'qtr2':56000,'qtr3':47000,'qtr4':49000},'yr2':
{'qtr1':44900,'qtr2':46100,'qtr3':57000,'qtr4':59000}}
6
32. TSS school celebrated volunteering week where each
section of class XI dedicated a day for collecting amount
for charity being supported by the school. Sections A
volunteered on Monday, B on Tuesday, C on Wednesday
and soon. There are six sections in class XI. Amounts
collected by sections A to F are
8000,12000,9800,11200,15500,7300.
Write a program to create a bar chart showing collection
amount. The graph should have proper title and axes
titles.
33. Considering the TSS school collection for charity of
previous example. Write a program to plot the collected
amount vs days using a bar chart. The ticks on X-axis
should have Day names. The graph should have proper
title and axes titles.
34. Prof Awasthi is doing some research in the field of
Environment. Write a Program to plot this data on a
horizontal histogram with this data.
35. Consider the reference table.Write a program to plot a bar
chart from the medals won by India. Make sure that Gold,
Silver, Bronze and Total tally is represented through
different colours
36. Given a series NFIB that contains reversed Fibonacci
numbers with Fibonacci numbers as shown below:
[0,-1,-1,-2,-3,-5,-8,-13,-21,-34,0,1,1,2,3,5,8,13,21,34]
37. Draw the histogram based on the Production of Wheat in
different Years
Year:2000,2002,2004,2006,2008,2010,2012,2014,2016,20
18. Production':4,6,7,15,24,2,19,5,16,4
SQL
38 Show databases
Program 01:
Write python code to create a series object
temp2 storing temperatures of seven days of
week. Its indexes should be ’Sunday’, ‘Monday’,
…..’Saturday’.
Screenshots:
Source Code:
import pandas as pd
import numpy as np
temp2=([33.5,41.3,42,44.6,46.8,49,42.1])
days=['mon','tue','wed','thru','fri','sat','sun']
s=pd.Series(data=temp2,index=days)
print(s)
9
Program 02:
A series object (say T1) stores the average
temperature recorded on each day of month.
Write code to display the temperatures recoded
on:(I)first 7 days (ii)last 7 days.
Screenshot:
Source Code:
t1=([33.5,41.3,42,44.6,46.8,49,42.1,43.4,40.9,33
.6,49,33,45,48.0,46.1,
36.9,33,35,43.5,38.4,25,32.6,25.9,24,29.6,28.3,2
3,27.8,25.9,])
10
s1=pd.Series(t1)
print(s1.head(7))
print(s1.tail(7))
Program 03:
Dataframe is:
Population Hospitals Schools
Delhi 10927986.0 189.0 7916.0
Mumbai 12691836.0 208.0 8508.0
Kolkata 4631392.0 149.0 7226.0
Chennai 4328063.0 157.0 7617.0
Bangalor 5678097.0 1200.0 1200.0
e
Use the above data frame and create another
data Frame and it must not contain the column
'Population' and the row Banglore.
Screenshot:
11
Source Code:
dic={'Population':
[10998765.0,12612345.0,4658912.0,4309812.0,56712
30.0],
'Hospitals':[189.0,208.0,149.0,157.0,1200.0],
'Schools':[7916.0,8508.0,7226.0,7617.0,1200.0]}
df=pd.DataFrame(dic,index=['Delhi','Mumbai','Kolkata',
'Chennai','Banglore'])
print(df)
df6=pd.DataFrame(df)
del df6['Population']
df6=df6.drop(['Banglore'])
print(df6)
Program 04:
12
Source Code:
import pandas as pd
aid={'Toys':[7916,8508,7226,7617],'Books':
[6189,8208,6149,6157],'Unifrom':
[610,508,611,457],'Shoes':
[8810,6798,9611,6457]}
df1=pd.DataFrame(aid)
df2=pd.DataFrame(aid,index=['Andhra','Odisha','
M.P','U.P'])
print(df2)
print(df2[['Books','Unifrom']])
print(df2.Shoes)
Program 05:
13
Screenshot:
Source Code:
import pandas as pd
df={'Old Price':[3000,5000,6900,7800],
'New Price':[3500,6000,7000,8000],
'Change':[500,1000,100,200]}
data=pd.DataFrame(df)
print(data)
Program 06:
14
Screenshot:
Source Code:
import numpy as np
import pandas as pd
s=pd.Series(np.linspace(24,64,5))
print(s)
Program 07:
Source Code:
import numpy as np
import pandas as pd
s1=pd.Series(np.tile([3,5],2))
print(s1)
Program 08:
Screenshot:
Source Code:
dic={'target':
[56000,70000,75000,60000],'sales':
[58000,68000,78000,61000]}
salesDf=pd.DataFrame(dic,index=['ZoneA','Zone
B','ZoneC','ZoneD'])
print(salesDf)
salesDf['Orders']=[6000,6700,6200,6000]
salesDf.loc['ZoneE',:]=[50000,45000,5000]
print(salesDf)
Program 09:
17
Write a program to create a dataframe from a ist
containing dictionaries of the sales performance
of four zonal offices. Zone name should be in a
row lables
Screenshot:
Source Code:
import pandas as pd
ZoneA={'Target':56000,'sales':58000}
ZoneB={'Target':70000,'sales':68000}
ZoneC={'Target':75000,'sales':78000}
ZoneD={'Target':60000,'sales':61000}
sales=[ZoneA,ZoneB,ZoneC,ZoneD]
salesDf=pd.DataFrame(sales,index=['ZoneA','Zo
neB','ZoneC','ZoneD'])
print(salesDf)
18
Program 10:
Consider two series object staff and salaries that
store the number of people in various office
branches and salaries distributed in these
brances,respectively.
write a program to create another series object
that stores average salary per branch and then
create a DataFrame object from these Series
objects.
Screenshot:
Source Code:
import pandas as pd
import numpy as np
staff=pd.Series([20,36,44])
salaries=pd.Series([279000,396800,563000])
avg=salaries/staff
org={'people':staff,'Amount':salaries,'Average':a
vg}
dtf5=pd.DataFrame(org)
print(dtf5)
19
Program 11:
A series object trdata consists of around 2500
rows of data.Write a program to print the
following details: #(i)Frist 100 rows of data
(ii)last 5 rows of data
Screenshot:
Source Code:
import pandas as pd
trdata=pd.Series(range(1,2501,1))
print(trdata)
print(trdata.head(100))
20
print(trdata.tail())
Program 12:
Number of students in class 1 1 and 12 in three
streams ('Science','Commerce','Humanities')are
stored in two Series objects c11 and 12.Write
code to find total number of students in classes
11 and 12,stream wise.
Screenshot:
Source Code:
import pandas as pd
c11=pd.Series(data=[30,40,50],index=['science',
'commerce','humanities'])
c12=pd.Series(data=[37,44,45],index=['science',
'commerce','humanities'])
print("total no.of students")
print(c11+c12)
21
Program 13:
Screenshot:
Source Code:
import pandas as pd
import numpy as np
d={"name":
['name1','name2','name3','name4','name5'],
"zone":
['zone1','zone2','zone3','zone4','zone5'],"sales":
[100,200,10,350,250]}
df=pd.DataFrame(d)
print(df)
22
Program 14:
Screenshot:
Source Code:
import pandas as pd
23
import numpy as np
s=pd.Series(data=[100,200,300,400,500],index=
['I','J','K','L','M'])
print("Original Data Series:")
print(s)
s=s.reindex(index=['k','I','M','L','J'])
print("Data Series after changing the order of
index:")
print(s)
Program 15:
Screenshot:
Source Code:
import pandas as pd
import numpy as np
24
d={"name":'name',"empno":1}
d1={"name":'name1',"empno":2}
d2={"name":'name2',"empno":3}
d3={"name":'name3',"empno":4}
s=pd.DataFrame([d,d1,d2,d3])
print(s)
Program 16:
Screenshot:
Source Code:
25
import pandas as pd
ser1=pd.Series([34567,890,450,67829,34677,78
902,356711,678291,
637632,25723,2367,11789,345,256517])
print(ser1[ser1>50000])
Program 17:
Screenshot:
Source Code:
26
import pandas as pd
s5=pd.Series([12,16,21,15,10,18])
print('series object s5:')
print(s5)
s6=s5*2
print('value in s6>15:')
print(s6[s6>15])
Program 18:
Screenshot:
27
Source Code:
import pandas as pd
s=pd.Series(50000,index=['Qtr1','Qtr2','Qtr3','Qtr
4'])
print(s)
Program 19:
Screenshot:
28
Source Code:
import pandas as pd
import numpy as np
section=['A','B','C','D','E']
contri1=np.array([6700,5600,5000,5200,np.NaN]
)
s=pd.Series(data=contri1*2,index=section,dtype
=np.float32)
print(s)
Program 20:
Write a Program to enter the number and print whether the
number is odd or even.
Screenshot:
29
Source Code:
num=int(input("Enter any number"))
if num%2==0:
print("Even Number")
else:
print("Odd Number")
Program 21:
Given a series that stores the area of some states
in km2. Write code to find out the biggest and
smallest three areas from the given Series.Given
series has been created like this:
Ser1=pd.series([34567,890,450,67892,34677,78
30
902,256711,678291,637632,25723,2367,11789,
345,256517])
Screenshot:
Source Code:
import pandas as pd
Ser1=pd.Series([34567,890,450,67892,34677,78
902,256711,678291,637632,25723,2367,11789,
345,256517])
print("Top 3 biggest areas are:")
print(Ser1.sort_values().tail(3))
print("3 smallest areas are:")
print(Ser1.sort_values().head(3))
Program 22:
31
Write a Python code to create a series object
'temp1' that stores temperature of seven days in
it. take any random seven temperature.
Screenshot:
Source Code:
deg=[17.6,25.6,20.9,33,10.4,12.6,29.8]
temp1=pd.Series(deg,index=['monday','tuesday'
,'wednesday','thursday','friday','saturday','sunda
y'])
print(temp1)
Program 23:
32
Write a program to rename indexes of ‘zonec’
and ‘zoneD’ as ‘cental’, and ‘dakshin’
respectively and the column name ‘target’ and
‘sales’ as ‘targeted’ and ‘achieved’ respectively
Screenshot:
Source Code:
print(temp1)
dict1={'target':
[56000,70000,75000,6000]},'sales':
[58000,68000,78000,61000]}
salesdf=pd.DataFrame(dict1,index=['zoneA','zon
eB','zoneC','zoneD'])
print(salesdf)
print('------RENAMING INDEX OF ZONE C AND
D-------')
print(salesdf.rename(index={'zoneC':'central','zo
neD':'dakshin'}))
print('-----RENAMING COLUMN AND TARGET AND
SALES--------')
33
print(salesdf.rename(column={'target':'targeted'
,'sales':'achieved'}))
Program 24:
object1 population stores the details of
population in four metro cities of India and
object2 avg income stores the total average
income reported in previous year in each of these
metros. Calculate income per capita for each of
these metro cities.
Screenshot:
Source Code:
population=pd.Series([10627986,12691836,4631
1836,4328063],\
index=['delhi','mumbai','kolkata','chennai'])
avgincome=pd.Series([72167810927986,850871
2691836,4226784631392,5261784328063],\
34
index=['delhi','mumbai','kolkata','chennai'])
percapita=avgincome/population
print("population in four metro cities")
print(population)
print("avg.income in four mrteo cities")
print(avgincome)
print("per capita income in four metro cities")
print(percapita)
Program 25:
Create and Display a dataframe from a 2D
dictionary,sales,which stores the quarter-wise
sales as. inner dictionary for two years,as shown
below sales={'yr1':
{'qtr1':34500,'qtr2':56000,'qtr3':47000,'qtr4':490
00},
'yr2':
{'qtr1':44900,'qtr2':46100,'qtr3':57000,'qtr4':590
00}}
Screenshot:
Source Code:
import pandas as pd
35
sales={'yr1':
{'qtr1':34500,'qtr2':56000,'qtr3':47000,'qtr4
':49000},
'yr2':
{'qtr1':44900,'qtr2':46100,'qtr3':57000,'qtr4
':59000}}
dfsales=pd.DataFrame(sales)
print(dfsales)
Program 26:
Screenshot:
Source Code:
36
dic={'A':[1,2,3,4],'B':[5,6,7,8],'C':[9,10,11,12]}
df=pd.DataFrame(dic)
print(df)
rows=len(axes [0])
cols=len(df.axes[1])
print("no.of rows:",rows)
print("no.of columns:",cols)
Program 27:
Screenshot:
37
Source Code:
import pandas as pd
avg_tem=[28.4,30.55,25,35,37,39,28,\
28,30.8,25.0,35,35.4,29,27.1,\
24,30,21,31,37,39,32.5,\
28,30,28.8,35,37,39,28,\
28,30,25]
Temp1 = pd.Series(avg_tem[:7])
Temp2 = pd.Series(avg_tem[8:15])
Temp3 = pd.Series(avg_tem[16:23])
Temp4 = pd.Series(avg_tem[23:30])
print('Average temp of week1 \n',
Temp1.sum()/7)
print('Average temp of week2 \n',
Temp2.sum()/7)
print('Average temp of week3 \n',
Temp3.sum()/7)
print('Average temp of week4 \n',
Temp4.sum()/7)
Program 28:
Three Series object store the marks of 10
students in three terms. Roll numbers of students
38
form the index of these Series objects. The Three
Series objects have the same indexes.
Calculate the total weighted marks obtained by
students as per following formula:
Final marks=25% Term 1+ 25% Term2+ 50%
Term3
Screenshot:
Source Code:
import pandas as pd
Term1 =
pd.Series([40,35,25,20,22,26,28,29,23,28])
Term2 =
pd.Series([28,15,37,38,45,41,48,47,30,20])
Term3 =
pd.Series([36,23,34,31,21,22,23,24,26,28])
final_mark = (Term1*25)/100 + (Term2*25)/100
+ (Term3*50)/100
print(final_mark)
39
Program 29:
Write a program to create a series object that
stores the table of number 5
Screenshot:
Source Code:
import pandas as pd
import numpy as np
tab = np.arange(5,55,5)
ser = pd.Series(tab)
print(ser)
40
Program 30:
Write a pogram to create a series object from
ndarray that stores characters from 'a' to 'g'.
Screenshot:
Source Code:
import pandas as pd
import numpy as np
arr = np.array(list('abcdef'))
print(arr)
s1 = pd.Series(arr)
print(s1)
41
Program 31:
Generally, ten different prices of a stock are
stored. However, for ABC Co. only 5 prices are
available for a day:[74.25,76.06,69.5,72.55,81.5]
Write a Program to create a bar chart with the
given prices:
The graph should be plotted between the
limits -2 to 10 on x-axis.
There should be tick for every plotted
point.
Screenshot:
Source Code:
Import matplotlib.pyplot as plt
Import numpy as np
pr=[74.25,76.06,69.5,72.55,81.5]
plt.bar(range(len(pr)),pr,width=0.4,color='pink')
42
plt.xlim(-2,10)
plt.title("Prices of Abc Co.")
plt.xticks(range(-2,10))
plt.ylabel("Prices")
plt.show()
Program 32:
TSS school celebrated volunteering week where
each section of class XI dedicated a day for
collecting amount for charity being supported by
the school. Sections A volunteered on Monday, B
on Tuesday, C on Wednesday and soon. There
are six sections in class XI. Amounts collected by
sections A to F
are8000,12000,9800,11200,15500,7300.
Write a program to create a bar chart showing
collection amount. The graph should have proper
title and axes titles.
Screenshot:
Source Code:
import matplotlib.pyplot as plt
43
import numpy as np
Col=[8000,12000,9800,11200,15500,7300]
x=np.arange(6)
plt.title("Volunteering Week Collection")
plt.bar(x,Col,color="indigo",width=0.25)
plt.xlabel("Days")
plt.ylabel("Collection")
plt.show()
Program 33:
Draw the histogram for population_ages = [22, 55, 62, 45, 21,
22,34,42,42,4,99,102,110,120,121,122,130,111,115,112,80,7
5,65,54,44,43,42,48] and bins = [0, 10, 20, 30, 40, 50, 60, 70,
80, 90, 100, 110,120,130] through python program with
suitable title and label.
Screenshot:
Source Code:
import matplotlib.pyplot as plt
44
population_age =
[22,55,62,45,21,22,34,42,42,4,2,102,95,85,55,11
0,120,70,65,55,111,115,80,75,65,54,44,43,42,48
]
bins = [0,10,20,30,40,50,60,70,80,90,100]
plt.hist(population_age, bins, histtype='bar',
rwidth=0.8)
plt.xlabel('age groups')
plt.ylabel('Number of people')
plt.title('Histogram')
plt.show()
45
Program 34:
Prof Awasthi is doing some research in the field
of Environment. For some plotting purposes he
has generated some data as:
mu=100
sigma=15
x=mu+sigma*numpy.random.randn(10000)
Write a program to plot this data on a horizontal
histogram with this data.
Screenshot:
46
Source Code:
import matplotlib.pyplot as plt
import numpy as np
mu=100
sigma=15
x=mu+sigma*np.random.randn(10000)
plt.hist(x,bins=30,orientation='horizontal',color=
['navy'])
plt.title('Research data Histogram')
plt.show()
Program 35:
Draw the histogram based on the Production of Wheat in
different Years
Year:2000,2002,2004,2006,2008,2010,2012,2014,2016,2018
Production':4,6,7,15,24,2,19,5,16,4
Screenshot:
Source Code:
47
import pandas as pd
import matplotlib.pyplot as plt
data={'Year':
[2000,2002,2004,2006,2008,2010,2012,2014,20
16,2018],\
'Production':[4,6,7,15,24,2,19,5,16,4]}
d=pd.DataFrame(data)
print(d)
x=d.hist(column='Production',bins=5,grid=True)
plt.show(x)
Program 36:
48
Source Code:
import matplotlib.pyplot as plt
import numpy as np
nfib=[0,-1,-1,-2,-3,-5,-8,-13,-21,-
34,0,1,1,2,3,5,8,13,21,34]
plt.plot(range(-
10,10),nfib,'mo',markersize=5,markeredgecolor=
'k',linestyle='solid')
plt.grid(True)
plt.show()
Program 37:
Consider the reference table 3.1. Write a
program to plot a bar chart from the medals won
by Australia . In the same chart, plot medals won
by India too
Screenshot:
49
Source Code:
SQL Queries
Screenshots & Source Code:
Query:show databases;
50
Screenshot:
02. Create table item_info1 having following fields information Icode of string
type,Inm of string type,Descp of string type,Price of decimal type, Qua of integer
type
Query:create table
item_info1(icodevarchar(20),item_namevarchar(20,descp
varchar(20),price decimal, Qua int);
Screenshot:
51
04.Display all the information of the table item_info1;
Query:select * from item_info1;
Screenshot:
52
07.Change the structure of table by adding a new column
Type char(20)
Query:alter table item_info1 add type char(20);
Screenshot:
Screenshot:
53
09.Show all the information about the “laptop” ;
Query: select * from item_info1 where item_name=’LAPTOP’;
Screenshot:
Screenshot:
54
12.Show maximum price of the item_info1 table.
Query:select max(price) from item_info1;
Screenshot:
Screenshot:
Screenshot:
55
Screenshot:
56
Screenshot:
57
Screenshot:
Screenshot:
Screenshot:
58
Screenshot:
Screenshot:
Bibliography
We took the information for our practical
report from the following sources:
59
Reference books:
1. Informatics Practices by Sumita
Arora.
2. Complete reference with Python
3. Data Analysis-Python.
Websites…
www.google.com
www.python.org.in
60