0% found this document useful (0 votes)
43 views

Pragya Girls School

The document is a half-yearly examination question paper for grade 12 students. It contains instructions, 5 sections with multiple choice, very short answer, short answer and long answer type questions related to Python Pandas library. Questions are on concepts like data types, data structures, functions and visualizations in Pandas.
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)
43 views

Pragya Girls School

The document is a half-yearly examination question paper for grade 12 students. It contains instructions, 5 sections with multiple choice, very short answer, short answer and long answer type questions related to Python Pandas library. Questions are on concepts like data types, data structures, functions and visualizations in Pandas.
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/ 8

PRAGYA GIRLS SCHOOL

Half Yearly Examination


Name: _________________________ Subject: Informatics Practices
Roll No.________________________ Academic Session: 2023-24
Date: 30/09/2023 Grade: XII
Duration: 03 Hours Maximum Marks: 70

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.

Q._No. Section A Marks


1. CSV stands for: 1
i. Column Separated Value ii. Class Separated Value
iii. Comma Separated Value iv. Comma Segregated Value
2. Which of the following command will show the last 3 rows from a Pandas 1
Series named NP?
i. NP.Tail( ) ii. NP.tail(3) iii. NP.TAIL(3) iv. All of the above
3. With reference to SQL, identify the invalid data type. 1
i. Date ii. Integer iii. Varchar iv. Month
4. In Python Pandas, while performing mathematical operations on series, index 1
matching is implemented and all missing values are filled in with _____by default.
i. Null ii. Blank iii. NaN iv. Zero
5. ASSERTION AND REASONING based question. 1
Mark the correct choice as:
Assertion (A):- To use the Pandas library in a Python program, one must import it.

Reasoning (R): - The only alias name that can be used with the Pandas library is pd.

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

--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

19. The python code written below has syntactical errors. 2


Rewrite the correct code and underline the corrections made.

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. stud.index b. stud.length c. stud.values d. stud.size


22. A social science teacher wants to use a pandas series to teach about Indian 2
historical monuments and its states. The series should have the monument names
as values and state names as indexes which are stored in the given lists, as shown
in the code. Choose the statement which will create the series:
import pandas as pd
Monument=['Qutub Minar','Gateway of India','Red Fort','Taj Mahal']
State=['Delhi','Maharashtra','Delhi','Uttar Pradesh']

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

a. import matplotlib.pyplot as plt


plt.plot([1,2],[4,5])
plt.show()
b. import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,5,1])
plt.show()
c. import matplotlib.pyplot as plt
plt.plot([2,3],[5,1])
plt.show()
d. import matplotlib.pyplot as plt
plt.plot([1,3],[4,1])
plt.show()

--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

31. Write the code in pandas to create the following dataframes : 4

Write the commands to do the following operations on the dataframes given


above :

(i) To add dataframes df1 and df2.


(ii) To subtract df2 from df1
(iii) To rename column mark1 as marks1in both the dataframes df1 and df2.
(iv) To change index label of df1 from 0 to zero and from 1 to one.
32. 4
Consider the table FANS and answer the following:
FANS

Write MySQL queries for the following:


i. To display the details of fans in decending order of their DOB
ii. To display the details of FANS who does not belong to AJMER
iii. To count the total number of fans of each fan mode
iv. To display the dob of the youngest fan.

--5--
Section E
33. Write suitable Python code to create 'Favourite Hobby' Bar Chart as shown below: 5

Also give suitable python statement to save this chart.

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:

Based on the given information, answer the questions No. A to E.

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

C. He wants to delete the row of science marks:


a. DF.drop('Science', axis=1) b. DF.drop('Science', axis=0)
c. DF.drop('Science', axis=-1) d. DF.drop('Science', axis==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']

F. What will be the output of the given command?

print(DF.size)

a. 15 b. 18 c. 21 d. 23

--8--

You might also like