Pragya Girls School
Pragya Girls School
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 02 questions carrying 04 marks each.
7. Section E has 03 questions carrying 05 marks each.
8. All programming questions are to be answered using Python Language only.
Reasoning (R): - The only alias name that can be used with the Pandas library is pd.
--1--
6. ASSERTION AND REASONING based question. Mark the correct choice as: 1
Assertion (A):- DataFrame has both a row and column index.
Reasoning (R): - A DataFrame is a two-dimensional labelled data structure like a table
of MySQL.
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
7. Which of the following can be used to specify the data while creating a DataFrame? 1
i. Series ii. List of Dictionaries iii. Structured ndarray iv. All of these
8. Which of the following statement will import pandas library? 1
i. Import pandas as pd ii. import Pandas as py
iii. import pandas as pd iv. import panda as pd
9. The name “Pandas” is derived from the term: 1
a. Panel Data b. Panel Series c. Python Document d. Panel Data Frame
10. The command to install the pandas is: 1
a. install pip pandas b. install pandas c. pip pandas d. pip install pandas
11. Python pandas was developed by: 1
a. Guido van Rossum b. Travis Oliphant c. Wes McKinney d. Brendan Eich
12. Pandas Series is: 1
a. 2 Dimensional b. 3 Dimensional c. 1 Dimensional d. Multidimensional
13. Pandas is a: 1
a. Package b. Language c. Library d. Software
14. We can analyse the data in pandas with 1
a. Series b. Data Frame c. Both of the above d. None of the above
15. Out of the following, which function cannot be used for customization of charts 1
in Python?
a. xlabel() b. colour() c. title() d. xticks()
16. What is the minimum number of arguments required for plot() function in 1
matplotlib?
a. 1 b. 2 c. 3 d. 4
17. Method or function to add a new row in a data frame is: 1
a. .loc() b. .iloc() c. join d. add()
18. _____________ is the function to save the graph. 1
a. Savefig() b. Savefigure() c. Savegraph() d. Savechart()
Section B
Import pandas as pd
df={"Technology":["Programming","Robotics","3DPrinting"],"Time(inmonths)":[4,4,3]}
df= Pd.dataframe(df)
Print(df)
--2--
20. What will be the output of the given code? 2
import pandas as pd
s = pd.Series([1,2,3,4,5],
index=['akram','brijesh','charu','deepika','era'])
print(s['charu'])
21. Assuming the given series, named stud, which command will be used to print 5 as 2
output?
Amit 90
Ramesh 100
Mahesh 50
John 67
Abdul 89
Name: Student, dtype: int64
a. S=df.Series(Monument,index=State) b. S=pd.Series(State,Monument)
c. S=pd.Series(Monument,index=State) d. S=pd.series(Monument,index=State)
23. Observe the following figure. Identify the coding for obtaining this as output. 2
--3--
24. Write the output of the given program: 2
import pandas as pd
S1=pd.Series([5,6,7,8,10],index=['v','w','x','y','z'])
l=[2,6,1,4,6]
S2=pd.Series(l,index=['z','y','a','w','v'])
print(S1-S2)
25. Which graph should be used where each column represents a range of values, and 2
the height of a column corresponds to how many values are in that range?
a. plot b. line c. bar d. histogram
Section C
26. Ritika is a new learner for the python pandas, and she is aware of some concepts 3
of python. She has created some lists, but is unable to create the data frame from
the same. Help her by identifying the statement which will create the data frame.
import pandas as pd
Name=['Manpreet','Kavil','Manu','Ria']
Phy=[70,60,76,89]
Chem=[30,70,50,65]
a. df=pd.DataFrame({"Name":Name,"Phy":Phy,"Chem":Chem})
b. d=("Name":Name,"Phy":Phy,"Chem":Chem)
df=pd.DataFrame(d)
c. df=pd.DataFrame([Name,Phy,Chem],columns=['Name',"Phy","Chem","Total"])
d. df=pd.DataFrame({Name:"Name", Phy :"Phy",Chem: "Chem"})
27. Consider the given DataFrame ‘Genre’: 3
Type Code
0 Fiction F
1 Non Fiction NF
2 Drama D
3 Poetry P
Write suitable Python statements for the following:
i. Add a column called Num_Copies with the following data: [300,290,450,760].
ii. Add a new genre of type ‘Folk Tale' having code as “FT” and 600 number of copies.
iii. Rename the column ‘Code’ to ‘Book_Code’.
28. Consider the following DataFrame, classframe 3
Write commands to :
i. Add a new column ‘Activity’ to the Dataframe having values as [‘Swimming’,’Dancing
’,’Cricket’, ‘Singing’]
ii. Add a new row with values ( 5 , Mridula ,X, F , 9.8, Science)
29. Write a code in Python to search for a given value in a list of elements(Without 3
using inbuilt function)
Example:
If the List contains: [20,30,40,50,60,80,120] and the element to be searched is:60.
Then the output should be: Found at position 4
--4--
30. Create a DataFrame in Python from the given list: 3
[[‘Divya’,’HR’,95000],[‘Mamta’,’Marketing’,97000],[‘Payal’,’IT’,980000],
[‘Deepak’,’Sales’,79000]]
Also give appropriate column headings as shown below:
Section D
--5--
Section E
33. Write suitable Python code to create 'Favourite Hobby' Bar Chart as shown below: 5
34. 5
Kabir has created following table named exam:
Help him in writing SQL queries to the perform the following task:
i. Insert a new record in the table having following values: [6,'Khushi','CS',85]
ii. To change the value “IP” to “Informatics Practices” in subject column.
iii. To remove the records of those students whose marks are less than 30 .
iv. To add a new column Grade of suitable datatype.
v. To display records of “Informatics Practices” subject.
--6--
35. Question 35, consists of 6 Question (A to F). Attempt any 5 questions. 5
Case Study
Mr. Sharma is working with an IT company, and he has provided some data. On which
he wants to do some operations, but he is facing some problem, help him:
Code:
import pandas as pd
ResultSheet={
'Naveen': pd.Series([90, 91, 97],
index=['Maths','Science','Hindi']),
'Rehana': pd.Series([92, 81, 96],
index=['Maths','Science','Hindi']),
'John': pd.Series([89, 91, 88],
index=['Maths','Science','Hindi']),
'Roja': pd.Series([81, 71, 67],
index=['Maths','Science','Hindi']),
'Mannat': pd.Series([94, 95, 99],
index=['Maths','Science','Hindi'])}
DF = pd.DataFrame(ResultSheet)
print(DF)
Output of the above code:
A. He wants to add a new column with name of student ‘Prem’ in above data frame
choose the right command to do so:
a. DF['Prem']=[89,78,76] b. df['Prem']=[89,78,76]
c. DF['Prem']=[89,78,76,67] d. DF['Name']=[89,78,76]
B. He wants to set all the values to zero in data frame, choose the right command to do
so:
a. DF=0 b. DF[]=0 c. DF[:]=0 d. DF[:]==0
D. The following code is to create another data frame, which he wants to add to the
existing Data frame. Choose the right command to do so:
Sheet1={
'Aaradhya': pd.Series([90, 91, 97],
index=['Maths','Science','Hindi'])}
S1=pd.DataFrame(Sheet1)
a. DF.append(S1,axis=0) b. DF.append(S1) c. DF.insert(S1) d. DF.join(S1)
--7--
E. What will be the output of the given command?
DF.index=['A','B','C']
print(DF.size)
a. 15 b. 18 c. 21 d. 23
--8--