0% found this document useful (0 votes)
7 views4 pages

Class 12 IP

The document outlines holiday homework for Class XII - IP at Shree Sanatan Dharm Education Centre for the academic year 2025-26. It includes multiple-choice questions on DataFrame attributes in Pandas, as well as programming tasks to create Series and DataFrames using various data structures. The homework is divided into two sections, with Section A focusing on theoretical questions and Section B on practical coding exercises.

Uploaded by

binus2842
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)
7 views4 pages

Class 12 IP

The document outlines holiday homework for Class XII - IP at Shree Sanatan Dharm Education Centre for the academic year 2025-26. It includes multiple-choice questions on DataFrame attributes in Pandas, as well as programming tasks to create Series and DataFrames using various data structures. The homework is divided into two sections, with Section A focusing on theoretical questions and Section B on practical coding exercises.

Uploaded by

binus2842
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/ 4

SHREE SANATAN DHARM EDUCATION CENTRE

HOLIDAY HOMEWORK
2025-26
Class XII- IP
Section A
Q1. What is the purpose of index attribute in dataframe:
(a) Fetch the dimension of the given dataframe
(b) Fetch the size of the given dataframe
(c) Fetch both index and column names of the given dataframe
(d) Fetch the index’s name in the dataframe
Q2. What is the purpose of ndim attribute in dataframe:
(a) Fetch the dimension of the given dataframe
(b) Fetch the size of the given dataframe
(c) Fetch both index and column names of the given dataframe
(d) Fetch the data type values of the items in the dataframe
Q3. What is the purpose of size attribute in dataframe:
(a) Fetch the dimension of the given dataframe
(b) Fetch the size of the given dataframe
(c) Fetch both index and column names of the given dataframe
(d) Fetch the data type values of the items in the dataframe
Q4. What is the purpose of axes attribute in dataframe:
(a) Fetch the dimension of the given dataframe
(b) Fetch the size of the given dataframe
(c) Fetch both index and column names of the given dataframe
(d) Fetch the index’s name in the dataframe
Q5. From the 6th display the 3rd, 4th and 5th columns from 6th to 9th rows of a dataframe DF, 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]
Q6. To change the 5th column’s value at 3rd row as 35 in dataframe DF you can write ________.
(a) DF.loc[4,6]=35 (b) DF[3,5]=35 (c) Df.iat[4,6]=35 (d) Df.iat[3,5]=35
Q7. Which among the following options can be used to create a DataFrame in Pandas?
(a) A scalar value (b) An ndarray (c) A python (d) All of these
Q8. What is the output of the following code:
import pandas as pd
resultDict={'Mohit':pd.Series([76,98,54], index=['Physics','Chemistry', 'Maths']),\
'Priya':pd.Series([65,87,43],index=['Physics','Chemistry', 'Maths']),\
'Deep':pd.Series([60,75,83],index=['Physics','Chemistry', 'Maths'])}
resultDF=pd.DataFrame(resultDict)
print(resultDF.T)
(a) Mohit Priya Deep (b) Physics Chemistry Maths
Physics 76 65 60 Mohit 76 98 54
Chemistry 98 87 75 Priya 65 87 43
Maths 54 43 83 Deep 60 75 83
(c) Wrong Code (d) None of these
Q9. Consider the following snippet:
import pandas as pd
resultDict={'Jyoti':pd.Series([76,98,54], index=['Physics','Chemistry', 'Maths']),\
'Vanshi':pd.Series([65,87,43],index=['Physics','Chemistry', 'Maths']),\
'Aviral':pd.Series([60,75,83],index=['Physics','Chemistry', 'Maths']),\
'Ankita':pd.Series([63,78,80],index=['Physics','Chemistry', 'Maths'])}
resultDF=pd.DataFrame(resultDict)
print(resultDF.count())
(a) Jyoti 3 (b) Physics 4
Vanshi 3 Chemistry 4
Aviral 3 Maths 4
Ankita 3 dtype: int64
dtype: int64
(c) Both (a) and (b) (d) None of these
Q1 Consider the following snippet:
0. import pandas as pd
resultDict={'Jyoti':pd.Series([76,98,54], index=['Physics','Chemistry', 'Maths']),\
'Vanshi':pd.Series([65,87,43],index=['Physics','Chemistry', 'Maths']),\
'Aviral':pd.Series([60,75,83],index=['Physics','Chemistry', 'Maths']),\
'Ankita':pd.Series([63,78,80],index=['Physics','Chemistry', 'Maths'])}
resultDF=pd.DataFrame(resultDict)
print(resultDF.T.count())
(a) Jyoti 3 (b) Physics 4
Vanshi 3 Chemistry 4
Aviral 3 Maths 4
Ankita 3 dtype: int64
dtype: int64
(c) Both (a) and (b) (d) None of these

Section B
1. Write code to create a Series object using the Python sequence [11,21,31,41]. Assume that Pandas is imported as
alias name pd.
2. Write code to create a Series object using the Python sequence (1,2,3,4). Assume that Pandas is imported as alias
name pd.
3. Write a program to create a Series object using individual characters ‘o’,’h’, and ‘o’. Assume that Pandas is
imported alias name pd.
4. Write a program to create a Series object using a string: “So funny”. Assume that Pandas is imported as alias
name pd.
5. Write a program to create a Series object using three different words : “I”, “am”, “laughing”.Assume that Pandas
is imported as alias name pd.
6. Write a program to create a Series object using an ndarray that has 5 elements in the ranges 24 to 64.
7. Write a program to create a Series object using an ndarray that is created by tiling a list [3,5], twice.
8. Write a program to create a Series object using a dictionary that stores the number of students in each section of
class 12 in your school.
9. Write a program to create a Series object that stores initial budget allocated (50000/- each) for the four quarters
of the years: Qtr1, Qtr2, Qtr3 and Qtr4.
10.Total number of medals to be won is 200 in the Inter University games held every alternate year. Write code to
create a Series object that these medals for games to be held in the decade 2020-2029.
11.A Python list namely section stores the section names (‘A’, ‘B’, ‘C’, ‘D’) of class 12 in your school. Another list contri
stores the contribution made by these students to a charity fund endorsed by the school. Write code to create a
Series object that stores the contribution amount as the values and the section names as the indexes.
12.Sequence section and contri1 store the section names (‘A’, ‘B’, ‘C’, ‘D’) and contribution made by them
respectively (6700, 5600, 5000, 5200, nil) for a charity. Your school has decided to donate as much contribution as
made by each section, i.e. the donation will be doubled.
13.Consider the rows series objects s11 and s12 that you created in examples 11 and 12 respectively. Print the
attributes of both these objects in a report form as shown below:
Attribute name Object s11 Object s12
Data type
Shape
No. of bytes
No. of dimensions
Item size
Has NaNs?
Empty?
14.Consider a Series object s8 that stores the number of students in each section of class 12 (as shown below)
Vanya 65
Sanya 87
Manya 89
15.Consider the Series object s13 that stores the contribution of each section, as shown below:
A 13400.0
B 11200.0
C 10000.0
D 10400.0
E NaN
16.A Series object trdata consist of around 2500 rows of data. Write a program to print the following details :

(i) First 100 rows of data (ii) Last 5 rows of data


17.Number of students in classes 11 and 12 in three streams (‘Science’, ‘Commerce’, ‘Humanities’) are stored in two
Series objects c11 and 12. Write code to find total number of students in classes 11 and 12, stream wise.
18.Object1 Population stores the details of population in four metro cities of India and Object2 AvgIncome stores the
total average income reported in previous year in each of these metros. Calculate income per capita for each of these
metro cities.
19.What will be the output produced by the following program?
import pandas as pd
info=pd.Series(data=[31,41,51])
print(info)
print(info>40)
print(info[infor>40])
20.Series object s11 stores the charity contribution made by each section (see below):
A 6700
B 5600
C 5000
D 5200
Write a program to display which section made a contribution more than Rs. 5500/-.
21.Given a dictionary that stores the section names’ list as value for ‘Section’ key and contribution amounts’ list as
value for ‘Contri’ key:
Dict1={‘Section’:[‘A’, ‘B’, ‘C’, ‘D’], ‘Contri’:[6700,5600, 5000, 5200]}
Write code to create and display the data frame using above dictionary.
22.Create and display a DataFrame from a 2D dictionary, Sales, which stores the quarter-wise sales as inner
dictionary for two years, as show below:
Sales={‘yr1’:{‘Qtr1’:34500, ‘Qtr2’:56000, ‘Qtr3’:47000, ‘Qtr4’:49000 },
{‘yr2’: {‘Qtr1’:47500, ‘Qtr2’:46100, ‘Qtr3’:56000, ‘Qtr4’:59000 }}
23.Carefully read the following code.
import pandas as pd
yr1={‘Qtr1’ :44900, ‘Qtr2’: 46100, ‘Q3’:57000, ‘Q4’:59000}
yr2={‘A’:54500, ‘B’ :51000, ‘Qtr4’:57000}
disSales1={1:yr1, 2:yr2}
df3=pd.DataFrame(diSales1)
(i) List the index labels of the DataFrame df3
(ii) List the column names of DataFrame df3.
24.Write a program to create a dataframe from a list containing dictionaries of the sales performance of four zonal
offices. Zones names should be the should be the row labels.
25.Write a program to create a dataframe from a 2D list. Specify own index labels.

You might also like