0% found this document useful (0 votes)
132 views6 pages

Ip 065 PT 4

1. The document provides instructions for a periodic test in Informatics Practices consisting of 5 sections with a total of 35 marks. 2. Section A contains 9 multiple choice questions carrying 1 mark each about Pandas and dataframes. Section B contains 3 very short answer questions carrying 2 marks each. Section C contains 2 short answer questions carrying 3 marks each. Section D contains 1 question carrying 4 marks. Section E contains 2 questions carrying 5 marks each. 3. The test is to be completed within 90 minutes and all questions are compulsory. General instructions provide details about the number of questions, marks and duration for each section.

Uploaded by

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

Ip 065 PT 4

1. The document provides instructions for a periodic test in Informatics Practices consisting of 5 sections with a total of 35 marks. 2. Section A contains 9 multiple choice questions carrying 1 mark each about Pandas and dataframes. Section B contains 3 very short answer questions carrying 2 marks each. Section C contains 2 short answer questions carrying 3 marks each. Section D contains 1 question carrying 4 marks. Section E contains 2 questions carrying 5 marks each. 3. The test is to be completed within 90 minutes and all questions are compulsory. General instructions provide details about the number of questions, marks and duration for each section.

Uploaded by

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

BHARATH VIDYA MANDIR

PERIODIC TEST IV
INFORMATICS PRACTICES (IP065)

DATE: 20.09.2023 MARKS: 35


CLASS: XII DURATION: 90 MINS
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 9 questions carrying 01 mark each.
4. Section B has 3 Very Short Answer type questions carrying 02 marks each.
5. Section C has 2 Short Answer type questions carrying 3 marks each.
6. Section D has 1 question carrying 04 mark.
7. Section E has 2 questions carrying 05 marks each.

SECTION A (20 MINS)(9*1 = 9 MARKS)

1. What is the correct syntax to return both the first row and the second row in a Pandas DataFrame df?
A) df.loc[[0,1]] B) df.[[0,1]] C) df.loc[[0-1]] D) df.[[0-1]]
2. If df is a dataframe then print(df) will print
A) The first ten rows B) The first five rows
C) The first five and last five rows D) The first ten and the last ten rows
3. Pandas Series can be created from:
A) Scalar values B) NumPy arrays C) Dictionary D). All of the above
4. Which function is used to find values from a DataFrame D using the index number?
A) D.loc B) D.iloc C) D.index D) None of these
5. Which attribute of a dataframe is used to convert a row into columns and columns into rows in a dataframe?
A) T B) ndim C) empty D) shape
6. The axis 1 identifies a dataframe's
A) row B) columns C) values D) datatype
7. To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe you can write
A) DF.loc[6:9, 3:5] B) DF.loc[6:10, 3:6] C) DF.iloc[6:10, 3:6] D) DF.iloc[6:9, 3:5]
8. To change the 5th column's value at 3rd row as 35 in dataframe DF, you can write
A) DF[4, 6] = 35 B) DF.iat[4, 6] = 35 C) DF[3, 5] = 35 D) DF.iat[3, 5] = 35
9. Assertion (A): Data visualization refers to the graphical representation of information and data using visual
elements like charts, graphs and maps etc.
Reason (R) : To install matplotlib library we can use the command pip install matplotlib.
A) Both A and R are true and R is the correct explanation of A
B) Both A and R are true but R is not the correct explanation of A
C) A is true but R is false
D) A is false but R is true

SECTION B (15 MINS) (3*2 = 8 MARKS)

10. Write a program to create a series from ndarray with elements ‘a’,’b’,’c’,’d’
11. Write python code to create the following series using Dictionary:
101 Harsh
102 Arun
103 Ankur
104 Harpahul
105 Divya
106 Jeet
12. Write python code to write DataFrame data into “a.csv” file.
SECTION C (20 MINS)(2*3 = 6 MARKS)

13. Consider the following code and answer questions:


Riyaz is creating an application using pandas library in his program , his code is mentioned below. Fill in
the blanks to help him
import _____ as pd #Statement A
d={‘a’:[1,2],’b’:[2,3]}
d2={‘a’:[4,5],’b’:[6,7]}
df1=pd.DataFrame(d)
df2=pd.________(d2) # Statement B
df3=pd._____([df1,df2]) # Statement C
A)Choose the right code from the following for statement A.
a) pandas b) df c) data d) pd
B)Choose the right code from the following for the statement B.
a) Dataframe b) DataFrame c) Series d) Dictionary
C)Choose the right code from the following for the statement C.
a) df.index b) df.shape() c) df.appenddf() d) df.concat()

14. Consider this Dataframe from all questions given below

A) Choose the correct function to rename city columns to location using rename() function:
a. df.rename(columns={‘City’:’Location’}) b. df.rename(columns={‘City’=’Location’})
c. df.rename(‘City’=’Location’) d. df.rename(df.columns(‘City’,’Location’))
B) df.index properties can be used to
a. rename rows b. rename columns
c. rename rows and columns both d. None of these
C)To display 2 rows from the top in the dataframe, which of the following statement is correct?
a. df.head()=2 b. df.head(n=2) c. df.head(range(2)) d. All of the above

SECTION D (10 MINS) (1*4 = 4 MARKS)

15. Mr.Sharma is trying to write a code to plot line graph shown in fig-1. Help Mr. Sharma to fill in the
blanks of the code and get the desired output.

import matplotlib.pyplot as plt # statement 1


x = [1,2,3] # statement 2
y = [2,4,1] # statement 3
plt.plot(x, y, color=’g’) #statement 4
______________ # statement 5
______________ # statement 6
# giving a title to my graph
plt.____________('My first graph!') # statement 7
# function to show the plot
_______________ # statement 8
i) Which of the above statement is responsible for plotting the values on canvas.
ii) Statements 5 & 6 are used to give names to x-axis and y-axis as shown in fig.1.Write the correct
code to fill those two blanks.
iii) Raman has executed code with first 7 statements. But No output displayed. which statement
will display the graph?
iv) The number of markers in the above line chart are

SECTION E (20 MINS) (2*5 = 10 MARKS)

16. ( i)Write python code to create the following series


101 Harsh
102 Arun
103 Ankur
104 Harpahul
105 Divya
106 Jeet
(ii) Show details of 1st 3 employees using head function
(iii) Show details of last 3 employees using tail function
(iv) Show details of 1st 3 employees without using head function
(v) Show details of last 3 employee without using tail function
(vi) Show value of index no 102
(vii) Show 2nd to 4th records
(viii) Show values of index no=101,103,105
(ix) Show details of “Arun”
17. If you are given to plot a histogram using numpy array as per the code given below then answer
any of four question from (i) to (v)
from matplotlib import _____ as plt
import numpy as np
fig, ax = plt.______ (1, 1)
a= np.array([26,59,44,39,76,16,23,11,18,78])
ax.hist(a, bins=[0,10,20,30,40])
ax._____ (‘Histogram’)
ax.set_xticks ([0,10,20,30,40, ])
ax.set_xlabel(‘Percentage’)
ax._______ (‘Students’)
______
(i) Write the correct option to import for given program:
(ii) Fill in the blank at Line 3
(iii) Which statement is used to set title in Line 6?
(iv) How to set Y-axis label?
(v) To fill in blank on Line 10 for showing histogram what can be used?

(LAST 5 Mins for Checking)


ANSWER KEY

1. What is the correct syntax to return both the first row and the second row in a Pandas DataFrame df?
A. df.loc[[0,1]] B. df.[[0,1]] C. df.loc[[0-1]] D. df.[[0-1]]
2. If df is a dataframe then print(df) will print
A. The first ten rows B. The first five rows
C. The first five and last five rows D. The first ten and the last ten rows
3. Pandas Series can be created from:
A. Scalar values B. NumPy arrays C. dictionary D. All of the above
4.Which function is used to find values from a DataFrame D using the index number?
a) D.loc b) D.iloc c) D.index d) None of these
5.Which attribute of a dataframe is used to convert rowa into columns and columns into rows in a dataframe?
a) T b) ndim c) empty d) shape
6.The axis 1 identifies a dataframe's
(a) row (b) columns (c) values (d) datatype
7.To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe you can write
(a) DF.loc[6:9, 3:5] (b) DF.loc[6:10, 3:6] (c) DF.iloc[6:10, 3:6] (d) DF.iloc[6:9, 3:5]
8. To change the 5th column's value at 3rd row as 35 in dataframe DF, you can write
(a) DF[4, 6] = 35 (b) DF.iat[4, 6] = 35 (c) DF[3, 5] = 35 (d) DF.iat[3, 5] = 35
9. Assertion (A) : Data visualization refers to the graphical representation of information and data using visual
elements like charts, graphs and maps etc.
Reason (R) : To install matplotlib library we can use the command pip install matplotlib.
A. Both A and R are true and R is the correct explanation of A
B. Both A and R are true but R is not the correct explanation of A
C. A is true but R is false
D. A is false but R is true
10. Write a program to create a series from ndarray with elements ‘a’,’b’,’c’,’d’
Ans.
import pandas as pd
import numpy as np
data =np.array([‘a’,’b’,’c’,’d’])
s =pd.Series(data)
print(s)
Its output is as follows –
0a
1b
2c
3d
dtype: object
11. Write python code to create the following series using Dictionary:
101 Harsh
102 Arun
103 Ankur
104 Harpahul
105 Divya
106 Jeet
import pandas as pd
D={101:“Harsh”,102:”Arun”,103:”Ankur”,104:”Harpahul”,105:”Divya”,106:”Jeet” }
s=pd.Series(D)
print(s)
106 Jeet
12. Write python code to write DataFrame data into “a.csv” file.
import pandas as pd
Dic={ ‘empno’: (101,102,103,104), ’name’:(‘a’,’b’,’c’,’d’),
’salary’: (3000,5000,8000,9000)}
df=pd.DataFrame(Dic)
df.to_csv(“a.csv”)
Note: csv can be opened in excel, notepad, etc.
13.Consider the following code and answer questions:
Riyaz is creating an application using pandas library in his program , his code is mentioned below. Fill in the
blanks to help him
import _____ as pd #Statement A
d={‘a’:[1,2],’b’:[2,3]}
d2={‘a’:[4,5],’b’:[6,7]}
df1=pd.DataFrame(d)
df2=pd.________(d2) # Statement B
df3=pd._____([df1,df2]) # Statement C
A)Choose the right code from the following for statement A.
a) pandas b) df c) data d) pd
B)Choose the right code from the following for the statement B.
a) Dataframe b) DataFrame c) Series d) Dictionary
C)Choose the right code from the following for the statement C.
a) df.index b) df.shape() c) df.appenddf() d) df.concat()
14.
Consider this Dataframe from all questions given below

A) Choose the correct function to rename city columns to location using rename() function:
a. df.rename(columns={‘City’:’Location’}) b.
df.rename(columns={‘City’=’Location’})
c. df.rename(‘City’=’Location’) d. df.rename(df.columns(‘City’,’Location’))
B) df.index properties can be used to
a. rename rows b. rename columns
c. rename rows and columns both d. None of these
C)To display 2 rows from the top in the dataframe, which of the following statement is
correct:
a. df.head()=2 b. df.head(n=2) c. df.head(range(2)) d. All of the above
SECTION D
15.
i) Which of the above statement is responsible for plotting the values on canvas.
a) Statement 8 b) Statement 4 c) Statement 1 d) None of the above
ii) Statements 5 & 6 are used to give names to x-axis and y-axis as shown in fig.1. Which of the
following can fill those two gaps
a) plt.xlabel('x - axis') plt.ylabel('y - axis') b) plt.xtitle('x - axis') plt.ytitle('y - axis')
c) plt.xlable('x - axis') plt.ylable('x - axis') d) plt.xlabel('x axis') plt.ylabel('y axis')
iii) Raman has executed code with first 7 statements. But No output displayed. which of the
following statements will display the graph?
a) plt.display() b) plt.show() c) matplotlib.pyplot.show() d) Both b & c
iv) The number of markers in the above line chart are
a) zero b) three c) Infinite d) One
16. (i) Write python code to create the following series
101 Harsh
102 Arun
103 Ankur
104 Harpahul
105 Divya
106 Jeet
(ii) Show details of 1st 3 employees using head function
(iii) Show details of last 3 employees using tail function
(iv) Show details of 1st 3 employees without using head function
(v) Show details of last 3 employee without using tail function
(vi) Show value of index no 102
(vii) Show 2nd to 4th records
(viii) Show values of index no=101,103,105
(ix) Show details of “Arun”
Ans.
(i) import pandas as pd
name=[‘Harsh’,’Arun’,’Ankur’,’Harpahul’,’Divya’,’Jeet’]
p=pd.Series(name,index=[101,102,103,104,105,106])
print (p)
(ii) print (p.head(3))
(iii) print (p.tail(3))
(iv) print(p[:3]) or pirnt(p.loc[101:103]) or print(p.iloc[0:3]) or print(p[[101,102,103]])
(v) print (p[-3:]) or print(p[3:]) or print(p[[104,105,106]])
(vi) print(p[102]) or print(p.loc[102])
(vii) print(p[1:4])
(viii) print(p[[101,103,105]])
(ix) print(p[p= =’Arun’])
17. If you are given to plot a histogram using numpy array as per the code given below then answer any of
four question from (i) to (v)
from matplotlib import _____ as plt
import numpy as np
fig, ax = plt.______ (1, 1)
a= np.array([26,59,44,39,76,16,23,11,18,78])
ax.hist(a, bins=[0,10,20,30,40])
ax._____ (‘Histogram’)
ax.set_xticks ([0,10,20,30,40, ])
ax.set_xlabel(‘Percentage’)
ax._______ (‘Students’)
______
(i) Choose the correct option to import for given program:
(a) matplotlib (b) matplot (c) pyplot (d) plot
(ii) Fill in the blank at Line 3
(a) subplots (b) subplot (c) plot (d) subplt
(iii) Which statement is used to set title in Line 6?
(a) title (b) set_title (c) set (d) Title
(iv) How to set Y-axis label?
(a) label () (b) set_y (c) set_ylab () (d) set_ylabel
(v) To fill in blank on Line 10 for showing histogram what can bee used?
(a) plt.show() (b) plt_show() (c) plot_show() (d) plt.show

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy