You are on page 1of 3

VEL’S PUBLIC SCHOOL,SANKARANKOVIL

GRADE-XII
INFORMATICS PRACTICES(065)
CUMULATIVE EXAMINATION-I
DURATION: 3 HRS ANSWER KEY-SET B MAX.MARKS:70
PART-A (15X1=15)
1 Reindex()
2 Comma separated value
3 Import pandas as pd
4 NaN
5 histh()
6 Discrete data
7 Plot()
8 Print(df.size)
9 Line plot
10 Print(max(df[‘score 2’])
11 Index
12 import matplotlib.pyplotas plt
13 to__csv(parameter)
14 Bar chart
15 Returns last n rows
PART-B (8X2=16)
1 import pandas as pd d={‘Name”:[‘RAJIV’,’SAMEER’,’KAPIL’],’Age’:[20,35,45],’Designation’:
[‘CLERK’,’MANAGER’,
’ACCOUNTANT’]}
df=pd.DataFrame(d)
2 The rename() function renames the existing indexes in dataframe whereas reindex() function is used
to change the order or existing lables in dataframe.
3 Pandas is the only library needed to bring data from a CSV file into a dataframe.It can be done in the
following manner.
Import pandas as pd
df = pd.read_csv(‘abc.csv)
4 plot()
show()
title()
xlabel()
ylabel()
explode()
bar()
hist()
box plot()
scatter()
5 No
First print appends the same elements again into the list as the * operator is used in list where as in
second print it performs arithmetic multiplication in the series.
[10, 20, 30, 40, 10, 20, 30, 40]
0 20
1 40
2 60
3 80
dtype: int
6 A 0
B 1
C 2
D 3
E 4
dtype: int64
A False
B False
C True
D True
E True
dtype: bool
A Z
B 2
C 3
D 4
E 5
dtype: object
7 This attribute is used to access a group of rows and columns by lable(s) or a boolean array in the
given series object.(syntax: series.loc)
This attribute enables purely integer location based indexing foe selection by position over the given
series object. (syntax: series.iloc)
8 Data visualization is the presentation of data in graphical format.It helps people understand the
significance of data by summarizing and presenting a huge amount of data in a simple and easy to
understand format and helps to communicate information clearly and effectively.
PART-C (8X3=24)
1 [40 50 60 70]
2 Series
A series can be seen as a one-dimensional array. The data structure can hold any data type, that is
includings strings, integers, floats and Python objects.
Ex:
import pandas as pd
s = pd.Series(['a','b','c'])

Import pandas as pd
D={‘maths’:[‘88’,’89’,’96’],’physics’:[‘88’,’97’,’99’]}
Df=pd.DataFrame()
3 Pandas is the only library needed to bring data from a CSV file into a data from a CSV file into a
dataframe.It can be done in the following manner.
Import pandas
Df=pandas.reas_csv(“abc.csv)
4 plt.bar(x,y)
Plt.xlabel(“No. of Students attended”)
5 A plot is a graphical technique for representing a data set, usually as a graph showing the
relationship between two or more variables. The plot can be drawn by hand or by a computer. In the
past, sometimes mechanical or electronic plotters were used.
A legend is an area describing the elements of the graph. In the matplotlib library, there's
a function called legend() which is used to Place a legend on the axes. The attribute Loc
in legend() is used to specify the location of the legend. 
6

7 import numpy as np
array_2D=np.identity(3)
print('3x3 matrix:')
print(array_2D)
8 It can process a variety of data set in different formats.
It facilitates loading and importing data from varied source such as CSV and DB/SQL.
PART-D (3X5=15)
1 (A)
import pandas as pd
import numpy as np
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily',
'Michael', 'Matthew', 'Laura', 'Kevin', 'Jonas'],'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8,
19],'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no',
'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
df = pd.DataFrame(exam_data , index=labels)
print("Rows where score between 15 and 20 (inclusive):")
print(df[df['score'].between(15, 20)])

(B) import pandas as pd


import numpy as np
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily','Michael', 'Matthew', 'Laura',
'Kevin', 'Jonas'],'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],'attempts' : [1, 3, 2, 3, 2, 3,
1, 1, 2, 1],'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}labels = ['a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j']
df = pd.DataFrame(exam_data , index=labels)
print("Number of attempts in the examination is greater than 2:") print(df[df['attempts'] <1])

2 import numpy as np
import matplotlib.pyplot as plt
Data=[ [5., 15., 25., 35.], [9., 18., 21., 15.,], [2., 18., 10., 30.], [13., 27., 20.,35.] ]
x=np.arange(4)
plt.plot(x, Data[0], color="b", label="Range1") plt.plot(x, Data[1], color="g", label="Range2")
plt.plot(x, Data[2], color="r", label="Range3") plt.plot(x, Data[3], color="y", label="Range4")
plt.legend(loc="upper left") plt.title('Multirange Line Chart')
plt.xlabel("X")
plt.ylabel("Y") plt.show()
3 Del df[‘column name’]

You might also like