0% found this document useful (0 votes)
13 views39 pages

Practical File Infomatics Practices 2024-25

Uploaded by

lokesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views39 pages

Practical File Infomatics Practices 2024-25

Uploaded by

lokesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 39

Sumermal Jain Public School

Session 2024-25
Name: Advaita Mishra
Stream: Commerce
Class: 12th-C
Roll Number:06
Certificate

this is to certify that advaita mishra (roll no.06


of class xii - c session 2024-2025 has prepared
the practical file as per the prescribed practical
syllabus of informatics practices cbse under
my supervision. iam completely satisfied by
the performance.

i wish her all the success in life.

External Examiner Mrs. Mamta Chaudhary


Signature (Subject Teacher)
TABLE OF CONTENTS —.

| Series from dictionary


Il DataFrame quarterly sales
lll Series using range function
IV DataFrame for examination result
V Duplicate rows
VI Series with range and for loop
VII Largest values in DataFrame
Vill Series for missing values using NaN
IX Series program to perform the objective

attribute function

X Series to perform mathematical and vector


operations

XI Importing and exporting data between pandas


and CSV file.

XII Series using HeadQ and Tail() function


XIII Series to access data with positions
XIV Series to access elements using ‘loc’ and ‘iloc'

XV Retrieve data from Series using some conditions

L y,
XVI
XVII

XVIII
XIX

XX
XX
XXII
XXill
XXIV

XXV
XXVI

XXVII.
XXVIII.

XXIX.

XXX.

CSV file and pandas

Visualization of school result data


Plotting charts with title and legend
Plotting functions on Matplotlib Library
Create table student

Inserting values

Delete the details of particular student


Select command

Remove extra spaces from left, right and

both sides from the text- "Informatics

Practices Class XII"

Foreign key
MinO, Max(),Sum(Q, Average() functions

Total customers using group by function

Write a SQL query to display names into


capital letters, small letters, display first 3
letters of name, display last 3 letters of

name, display the position the letter A in

name

SQL Query
Display today's date in "Date/Month/Year"

Format
XXXI.

XXXII.

XXXiIll.
XXXIV.

XXXV.
XXXVI.

XXXVII.

XXX VIII.

XXXIX.

XXXX.

Display dayname, monthname, day,


dayname, day of month, day of year for
today's date

Create a database OFFICE

Use the database OFFICE

Create a table EMPLOYEE and insert tuples


in it.

Display the details of all the EMPLOYEES

Display the details of all the employees in


the ascending order of their salary and
within salary in the descending order of
their join date.

Increase the bonus by 0.5% for all the


employees for which the salary is more

than 400000.

Add another column Category of type


CHAR(5) in the Employees table

Create table fees due with columns

Admno, month, Amt_due.

Using equi join display appropriate data


of those students who have not paid

their fees for previous month yet.


XXXXI. Display city and highest marks of students
of each city, but only for Delhi and

Mumbai in descending order of city.


Practical File - Informatics Practices (Class XIil)

#1 Create a pandas series from a dictionary of values and an ND array.

* Umport the paneas Lip as pe


import pandas as pd

# create a dictionary
dictionary « ('t' : #, 3B, Cs

# creote @ series
series » pd.Serles(¢ictlonary

print( series)
4 Wt
' ®
¢c

dtype: Intéd
#2. Create a Data Frame quarterly sales where each row contains the
item category, item name, and expenditure. Group the rows by the
category, item name and expenditure.

import pandas as pd

dice{‘itemcat':['car’,'kc’,'Aircoller’ , Washing Machine’),


‘temnane’:("Ford", "Hitachi", ‘Symphony’, LG"),
‘expenditure’: [7008000 52000, 12002, 14802))

quartsales«pd.Datafrane(dic)

print(quartsales)

qsequartsales.groupby(‘itescat’)

print("Result after Filtering Dataframe’)

print(qs[“itescat’, ‘expenditure’ ].sua())

itemcat itemase expenditure

@ car Ford TeeeeRE

1 Me Hitachi sere

ri Aircoller Symphony 12088

3 Washing Machine LG 14aee

Result after Filtering Datafrane


expenditure

itencat

Ac Seeee

Aircoller 12008

Washing Machine 14800

tar Re caaad
#3. Create a Pandas Series using Range Function.

Program:

import pandas as pd
s1=pd.Series(range(5))
s2=pd.Series(range(1,6,2))
print(s1)

print(s2)

Output:
#4. Create a data frame for examination result and display row labels,
column labels data types of each column and the dimensions

import pandas as pd

dics{*Class’:['I', II ,u, wT, 4, a, ON, TT, eS, ee,


‘Pass-Percentage’ :[108, 100, 100,100, 100, 108, 188, 180, 108, 98.6, 188, 99] }

result»pd.DataFrame(dic)

orint(result}

print(result.dtypes)

print(‘shape of the dataframe is:::::°)

print(result.shape)

Class Pass-Percentage

Q I 100.8
1 100.8
a 100.0
3 WW 100.8
4 V 108.0
5 VW 102.8
6 VII 100.2
7 Vl 100.2
ee 100.8
9 x 98.6
10 Xl 100.8
11 XII 99.8
Class object
Pass-Percentage floatéé
dtype: object

shape of the dataframe is:::::


(12, 2)
#5. Filter out rows based on different criteria such as duplicate rows.

import pandas as pd
dice{'Name':['Rohit’, ‘Mohit’, Deepak’ ,"Rohit', ‘Deepak’, ‘Sohit’ , Geeta’),

‘NarksinIP’;(85, 45, 92,85,92,96,84)}


narks=pd .DataFrane(dic)
# Find duplicate rows
duplicateRow = marks[marks.duplicated(keep-False) |
print (duplicateRow)

Name MarksinI?

@ Rohit a5
2 Deepak 92
3} Rohit 85

4 Deepak 92
#6. Create a Pandas Series with range and for loop.

Program:

import pandas as pd
s=pd.Series(range(1,15,3),index=[x for x in ‘abcde’])
ss=pd.Series(range(0,5),index=[x for x in ‘abcde’])
print(s)

print(ss)

Output:
#7. Locate the 3 largest values in a data frame.

import pandas as pd
dics{"Niane’:["Ronit’, Mohit’, "Deepak, "Anil", Pankaj’, 'Sohit’, Geeta’),

‘wack ind?’ (85, 45,92, 85, 98, 96, 84]}


narks=pd.DataFrane( dic)
# Find 3 Lorgest Volue for Marksinl? Coluan
print (marks nlargest(3,['NarksinI?’ }))

ane Marksinl?
4 Panka} 38
5 Shit %

2 Deepak 92
#8. Create a Pandas Series for missing values using NaN (Not a
Number)

Program:

import pandas as pd

import numpy as np

s=pd. Series([7.5,4,4.5,np.NaN, -34.5])


print(s)

Output:
#9. Write a Pandas Series Program to Perform Some of the
Object Attribute Functions.

Program:

import pandas as pd
data=pd.Series(range(1,15,3),index=[x for x in ‘abcde’])
print(data)

print(‘Has NaNs: ',data.hasnans)


print(‘Shape : ',data.shape)
print('Data Type : ‘,data.dtype)
print(‘Dimension : ',data.ndim)
print(Index Value : ',data.index)
print('No.of Bytes: ‘,data.nbytes)
print(Values in Series: ',data.values)
print('Size : ',data.size)

print('Series Empty: ',data.empty)

print(‘Axis: ',data.axes)

Output:
#10. Create a Pandas Series to perform the Mathematical and
Vector Operations on Series Elements.

Program:
import pandas as pd
$1=pd.Series([11,12,13,14,15])
s2=pd.Series([22,24,23,24,25])
$3=pd.Series([11,12,13,14,15], index=([101, 102,103,104, 105]))
print(‘Addition :’.s1+s2)
print(‘Subtraction :',s2-s1)
print(‘Multiplication :',s1*s2)
print(‘Division :",s2/s1)
print(‘Floor Division :’,s2//s1)
print(‘Modules :",s2%s1)
print('Addition :' 51453)
print("Vector Multiply:',s1*3)
print(‘Vector Multiply:’,s2+10)
print(‘Vector Power:’,s1°*2)
Output:
#11. Importing and exporting data between pandas and CSV file

* isporting pandas sodule


impert pandas as pd

# woking dota from

df = pd.read_csv("E:\emp.cow")
print(d#)

eapid engre doj


@ 101 Sachin Bhardwaj = 12-01-2012
1 182 Vinod Verea 15-01-2012
2 183 Anand Ganesh 05-09-2007

| import pandas as pd
l= [{"Wame’: Sachin’, ‘Sirllane’:Bhardvaj'},
{"Wame’: Vinod’, "Sirliane’:"Veraa’},
: { "Wame': "Rajesh", Sirllame’: Mishra’}]
dflepd.DataFrane(1)
# soving the datafrome
df1.to_csv("E:\Dataframel csv’)

His ce net foe) Few — k


1 tree 8 ES > sh SCRE Feri: 6-5 +94 Oe
Ome — s — _ |
#12. Create a Pandas Series using Head () and Tail ()
Functions.

Program:

import pandas as pd
HT=pd.Series((8,10,17,18,19,25,26,30].
index=['a’,'b’,'c’,'d’,'e’, f,'g’,''])
D=pd.Series({1:1.1,2:22,3:33.,4:44,5:5.5,6:66,7:7.7})
print(HT)

print(HT.head())

print(HT .tail())

print(HT.head(3))

print(HT. tail(2))

print(D)

print(D.head(3))

print(D.tail(2))

Output:
#13. Create a Pandas Series to access data from it, with position
(Slicing & Indexing).

Program:
import pandas as pd
s=pd.Series(/1,2,3,4,5],index=['a’,b’,'c’,'d’,’e’])
print(s)
print(s[O])
print(s[‘c’])
print(s[:3])
print(s[-3:])
print(s[1:5])
print(s[2:-2])

Output:
#14. Create a Pandas Series to access elements of series using
‘loc’ and ‘iloc’.

Program:
import pandas as pd
s=pd.Series((1,2,3,4,5],index=['a’,'b’,‘c’,‘d’,'e'))
ss=pd.Series(['a’,'b’,'c’,'d’,'e'],index=[1,2,3,4,5])
print(s.iloc{1:4])
print(s.loc['b’:'e'])
print(ss.iloc[2:5])
print(ss. iloc[2:-2])

Output:
#15. Create a Pandas Series & Retrieve the Data using Some
Conditions

Program:
import pandas as pd
s=pd.Series((1,2,3,4,5],index=['a’,’b’,'c’, d’,'e’])
ss=pd.Series([10,20,30,40,50],index=(1,2,3,4,5])
print(s<10)
print(ss[ss<30])
print(ss[ss==10])

print(ss[ss>=30))

print(ss[ss!=3])

Output:
#16. Create a program for Importing and Exporting Data between
Pandas and CSV File.

Program:
import pandas as pd
print(“\n")
Name=['Mahi’,"Yuvi',Kohii’,"Rohit’,, ABD’]
Degree=['B.E','MBA’,’M. Tech’, MBBS’,M.E]
Score=(490,488,492,496 482]
dict=(‘Name":Name, ‘Degree’-Degree, Score’:Score}
df=pd. DataFrame(dict)
print(" The File 'Exp.CSV* is Created(Imported) “)
df.to_csv(‘Exp.csv)
print(“\n")
df2=pd.read_csv(‘FILE3.csv)
print(“\n")
print(" The File Content of 'FILE3.csv' is Received(Readed)\n *)
df2.index.name='Index_No’
print(df2)
Output:

A a Ge
HM

Mh os

Pad G4

1 AAA

ae eee

Aone)
#17. Given the school result data, analyse the performance of the
students on different parameters, e.g subject wise or class wise.

inport matplotlib.pyplot as plt

Subject "Physics’, Chemistry’, ‘Hindi’, Biology’, CoaputerSc’]


Percentage[85, 78,65, 92, 128]
plt. bar(Subject, Percentage, align=center” colors" green’)
olt.xlabel( “SUBJECTS ME")

plt.ylabel( "PASS PERCENTAGE”)

plt.title( "Sar Gragh For Result Analysis’)

plt. show(

Bar Graph For Resutt Analysis

PASS PERCENTAGE

Physics Chemistry «Hindi = Bicloy Computer’


SUBECTS MAME
#18. For the Data frames created above, analyze and plot

appropriate charts with title and legend.

import natplotlib.pyplot
import numpy as np

Se[ ‘Ist’, '2nd', 3rd")


per_sc=(95,89,77]
per_com=(98, 93,75]
per_hum=[97, a, 17)
Xenp.arange(Len($))

plt.bar(x+.25,per com, label’ commerce” widthed

plt.bar(x+.5@,per hum, ]
plt.xticks(x,$)

plt.ylabel( ‘Percentage’ )
plt.title( ‘Bar Graph Fe
olt. legend)

plt. show( )

a plt

25, color='red

nities® ,[email protected], colors gold’)

Bar Graph For Result Analysis

100

Percentage

lst

== Sierce
= commerce
ee Humanites

Post ror

—J
19. Take Data of your interest from an open source (e.g, data.gov.in),
regate and summarize it. Then plot it using different plotting
unctions of the Matplotlib Library.

Program:

import pandas as pd

import matplotlib.pyplot as pl
cf=pd.read_csv("PEDV.csv")

print(cf,"\n')

s=(cf["Team’].head(12))
$2=(cf['Salary’].head(12))

pl.bar(s,s2)

pl.xlabel('Name of the Team’, fontsize=18)


pl.ylabel("Salary Range’, fontsize=18)
pl.title(‘Aggregated and Summarized Data’,fontsize=22)
pl.legend(‘Salary’, loc="best’)

pl.show()
Output:

a .
ad ™ -— 2 ee
- =
ee « 5
wn. = ” =m =
= = un te
a fae -
a * a Pa
' =
* - - —-
er - =
a . = f
a = 4 a at
ci Ams *
- im
«

Aggregated and Summarized Data

= ‘ae
moots 4
ooo 4
0000 |
POOOG 4

ae Ergpaed Sew [eater our Ate a Wet Peers,

Name of the Team

Salary Range
#20. Create a student table with the student id, name, and marks as
attributes where the student id is the primary key.

#21. Insert the details of a new student in the above table.

#22. Delete the details of a particular student in the above table.


#23. Use the select command to get the details of the students
with marks more than 80.

#24, Remove extra spaces from left, right and both sides from the text
- “Informatics Practices Class XII"

Select Itrim(* Informatics Practices Class XII") “Left Spaces’,


rtrim(" Informatics Practices Class XI| ") “Right Trim”, trim(“Informatics
Practices Class Xl *);

sal) select ltria(” Informatics Practices Class C1]

*) “Right Tria", tria(* Informatics Practic

Left Spaces

[rrormatics Practices Class 0]

row in set (6.08 gx


#25. Create a foreign key in one of the two tables mentioned above

mysql> alter table orders add foreign key(customerid) references customer


(customerid);
Query OK, 3 rows affected (1.22 sec)

#26. Find the min, max, sum, and average of the marks in a student
marks table.

#27. Find the total number of customers from each country in the table
(customer ID, customer Name, country) using group by.

mysql> select country,count(*) “TOTAL CUSTOMER” from customer group by country;


| country TOTAL CUSTOMER

beeen ween ee prc etree ween eee +


| AUSTRALIA 2
| INDIA F 4

pPSsesesesess pS SSSS555S45555S55, -
#28. Write a SQL query to display names into capital letters,
small letters, display first 3 letters of name, display last 3
letters of name, display the position the letter A in name

#29, Write a SQL query to order the (student ID, marks) table in
descending order of the marks.

student_id, sarks student


#30. Display today’s date in “DD/MM/YYYY” format.

#31. Display dayname, monthname, day, dayname, day of


month, day of year for today’s date.
#32. Create a database OFFICE

Create database OFFICE;

#33. Use the database OFFICE

Use OFFICE:

#34. Create a table EMPLOYEE and insert tuples in it.

Create Create table EMPLOYEE (ENO integer(5), ENAME varchar(50),SALARY


integer(10) AREACODE integer(5),BONUS decimal(4,2)DATE_OF_JOIN date);
Insert into EMPLOYEE values (1120,“Mahesh" 54000, 12,45.5,"01-12-2010");

#35. Display the details of all the EMPLOYEES

Select * from EMPLOYEE:

fi = fF ra

Mii
#36. Display the details of all the employees in the ascending
order of their salary and within salary in the descending order

of their join date.

Select * from EMPLOYEE order by SALARY asc, DATE OF JOIN desc:

"AM
AMM

Vee

‘al ml al bl at
» Ae
al et ot hl dal
eal e dh) hla

#37. Increase the bonus by 0.5% for all the employees for which
the salary is more than 400000

Update EMPLOYEE set BONUS=BONUS+(0.5/100)"BONUS, where


SALARY>400000;

ub. Ve ;
#38. Add another column Category of type CHAR(S5) in the
Employees table

Alter table EMPLOYEE add CATEGORY char(5);

er table EAPLOYEE add CATEGOR,


y row if Fé ted ¢(A.27? ec)
Du pl ic Ate : Warning :

enployee;
Type

Lit «

H YAP i’
Lint
int

mo ru i dei ima l4 4a ,

: do} | date
| CATEGORY i chart5>)
* *

, Pow Lm et (Mw
#39, Create table fees_ due with columns Admno, month,
Amt_ due.

Create table fees_due(tmo int primary key,


Month varchar(10)

Amt due double(7,2)


Admno int references student(admno))
Insert into fees_due values(101,’May’,9850,8102);
Insert into fees_due values(102,’April’,10050,8105),
Insert into fees_due values(103,’May’,9750,8105);
Insert into fees_due values(104,’May’,9950,8108);

#40.Using equi join display appropriate data of those students


who have not paid their fees for previous month yet.

Select trno, name, class, sex, month, amt_ due from students, fess due
Where student.admno=fees_due.admno;
#41. Display city and highest marks of students of each city, but only
for Delhi and Mumbai in descending order of city.

Select city, max(Marks) from student group by city having city in


(‘Delhi’,, Mumbai’) Order by city desc;

You might also like