AmbifulWorksheets
Practice that never repeats
CBSE · Class 12 · Informatics Practices

Data Handling using Pandas – I

Standard difficulty · 20 questions · 40 marks · Time: 40 minutes

Name: Date: Score: ____ / 40

Show your working for Sections B and C. Answers are on the last page — try every question first!

Section A — Choose the correct answer8 × 1 = 8 marks
1.
A pandas Series is:
  1. a kind of chart
  2. a database server
  3. a two-dimensional table
  4. a one-dimensional labelled array
2.
Series s:
A | 83
B | 80
C | 72
D | 85
E | 66
Which labels does s.iloc[0:2] show?
  1. B
  2. A
  3. A, B
  4. A, B, C, D, E
3.
Series s:
Mon | 60
Tue | 42
Wed | 54
Thu | 55
Fri | 58
Sat | 75
Which values does print(s[s > 58]) show?
  1. 60, 75
  2. 60, 58, 75
  3. 60, 54, 75
  4. 42, 54, 55, 58
4.
DataFrame df:
index | Item | Store | Price | Stock
P1 | Diary | West | 76 | 45
P2 | Folder | East | 88 | 65
P3 | Stapler | East | 74 | 84
P4 | Pen | East | 62 | 73
P5 | Marker | South | 79 | 77
After this statement, what does print(df.shape) show?
df = df.drop('P1')
  1. (5, 3)
  2. (5, 4)
  3. (4, 5)
  4. (4, 4)
5.
DataFrame df:
index | Name | Dept | Q1 | Q2
E1 | Tara | Support | 45 | 78
E2 | Manav | Training | 57 | 86
E3 | Arjun | Support | 54 | 82
E4 | Kabir | Training | 21 | 66
E5 | Isha | Design | 24 | 45
E6 | Sana | Design | 39 | 53
What does print(df.loc['E6', 'Q2']) show?
  1. 53
  2. 45
  3. 39
  4. 54
6.
DataFrame df:
index | Item | Store | Price | Stock
P1 | Sharpener | North | 20 | 64
P2 | Pen | East | 46 | 30
P3 | Stapler | East | 75 | 69
P4 | Marker | North | 59 | 13
P5 | Glue | East | 24 | 23
P6 | Crayons | West | 36 | 12
What does print(df.iloc[4, 2]) show?
  1. 23
  2. 36
  3. 24
  4. 59
7.
Series s:
a | 79
b | 44
c | 95
d | 91
e | 55
f | 29
Which labels does s.tail(2) show?
  1. e
  2. e, f
  3. f
  4. c, d, e, f
8.
s = pd.Series(9, index=['Jan', 'Feb', 'Mar', 'Apr'])
What does print(s.sum()) show?
  1. 9
  2. 36
  3. 4
  4. 13
Section B — Short answer8 × 2 = 16 marks
9.
Give two differences between a Series and a DataFrame.
10.
Series s:
Jan | 74
Feb | 62
Mar | 59
Apr | 29
May | 76
Write the output of:
print(s.loc['Jan':'May'].sum())
11.
DataFrame df:
index | Name | City | Maths | Science
S1 | Diya | Surat | 98 | 90
S2 | Meena | Pune | 94 | 78
S3 | Ravi | Pune | 56 | 93
S4 | Rohan | Shimla | 54 | 64
S5 | Zoya | Surat | 61 | 43
Write the output of:
print(len(df[df['Science'] >= 64]))
12.
DataFrame df:
index | Name | City | Maths | Science
S1 | Dev | Kochi | 84 | 84
S2 | Ravi | Pune | 69 | 74
S3 | Isha | Jaipur | 89 | 58
S4 | Neha | Kochi | 88 | 79
S5 | Manav | Pune | 45 | 57
Write the output of:
print(df['Science'].count())
13.
DataFrame df:
index | Name | Dept | Q1 | Q2
E1 | Vikram | Sales | 72 | 65
E2 | Isha | Sales | 89 | 91
E3 | Imran | Design | 43 | 93
E4 | Sana | Training | 23 | 88
E5 | Manav | Sales | 65 | 47
E6 | Arjun | Sales | 40 | 34
These statements run one after another:
df['Total'] = df['Q1'] + df['Q2']
df = df.drop('E5')
df = df.drop('Name', axis=1)
What does print(df.shape) show now?
14.
Series s:
Mon | 82
Tue | 47
Wed | 44
Thu | 95
Fri | 81
Write the output of:
print(s + 11)
(Write one "label | value" line for each element.)
15.
DataFrame df:
index | Name | City | Maths | Science
S1 | Karan | Patna | 67 | 67
S2 | Imran | Jaipur | 43 | 88
S3 | Kabir | Patna | 35 | 96
S4 | Ravi | Delhi | 61 | 35
S5 | Rohan | Delhi | 90 | 38
S6 | Manav | Jaipur | 92 | 41
Which values does print(df.loc['S2':'S3', 'Name']) show? Write them in order, separated by commas.
16.
DataFrame df:
index | Name | City | Maths | Science
S1 | Kabir | Pune | 82 | 80
S2 | Dev | Surat | 67 | 42
S3 | Rohan | Mysuru | 59 | 82
S4 | Sana | Mysuru | 53 | 99
S5 | Isha | Pune | 95 | 62
S6 | Vikram | Surat | 87 | 91
Write the output of:
print(df.iloc[0])
(Write one "label | value" line for each element.)
Section C — Word problems4 × 4 = 16 marks
17.
Explain how a DataFrame can be created from (a) a dictionary of lists, (b) a list of dictionaries, (c) a CSV file. Write one statement for each.
18.
DataFrame df:
index | Name | Dept | Q1 | Q2
E1 | Kabir | Design | 36 | 94
E2 | Vikram | Accounts | 86 | 36
E3 | Karan | Training | 65 | 65
E4 | Sana | Training | 58 | 73
E5 | Asha | Design | 23 | 69
E6 | Pooja | Design | 74 | 68
Write the output of:
print(df[df['Q1'] >= 58][['Name', 'Q1']])
19.
DataFrame df:
index | Name | City | Maths | Science
S1 | Imran | Jaipur | 75 | 68
S2 | Dev | Jaipur | 52 | 78
S3 | Asha | Jaipur | 46 | 75
S4 | Diya | Pune | 57 | 42
S5 | Pooja | Kochi | 39 | 36
This statement runs first:
df['Total'] = df['Maths'] + df['Science']
Write the output of:
(a) print(df.shape)
(b) print(df.loc['S2', 'Total'])
(c) print(df['Total'].min())
20.
Series s:
a | 38
b | 96
c | 75
d | 29
e | 61
f | 56
Write the output of each statement, and say why they differ.
(a) print(s.loc['b':'f'])
(b) print(s.iloc[1:5])
AmbifulWorksheets
Practice that never repeats
CBSE · Class 12 · Informatics Practices

Answer key

Data Handling using Pandas – I · AW-12IP-PD1-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.

QAnswerWorking
1(d) a one-dimensional labelled array—
2(c) A, Biloc slices by position: 0 up to, not including, 2
3(a) 60, 75keeps the elements where s > 58
4(d) (4, 4)drop with a row label (axis=0) removes a row
5(a) 53row E6, column Q2
6(c) 24iloc counts rows and columns from 0: row P5, column Price
7(b) e, ftail(2) shows the last 2 elements
8(b) 36a scalar is repeated for each of the 4 labels
9A Series is one-dimensional and has one index; a DataFrame is two-dimensional with a row index and column labels. A Series holds values of one column; a DataFrame can hold several columns of different types.—
10300Jan to May, both included: 74 + 62 + 59 + 29 + 76
114the rows where Science >= 64
125count() of column Science
13(5, 4)rows: 6 − 1; columns: 4 + 1 − 1
14Mon | 93
Tue | 58
Wed | 55
Thu | 106
Fri | 92
the operation is applied to every element; the labels stay
15Imran, Kabirrows S2 to S3, both included
16Name | Kabir
City | Pune
Maths | 82
Science | 80
iloc[0] is the row at position 0: S1
17(a) pd.DataFrame({'Name': ['Asha', 'Ravi'], 'Marks': [78, 85]}): keys become columns. (b) pd.DataFrame([{'Name': 'Asha', 'Marks': 78}, {'Name': 'Ravi', 'Marks': 85}]): each dictionary is a row. (c) pd.read_csv('marks.csv'): the file’s first line gives the column names.one mark each; one for correct explanation
18index | Name | Q1
E2 | Vikram | 86
E3 | Karan | 65
E4 | Sana | 58
E6 | Pooja | 74
rows where Q1 >= 58, only the columns Name and Q1
19(a) (5, 5); (b) 130; (c) 75Total = Maths + Science for each row; one column is added
20(a)
b | 96
c | 75
d | 29
e | 61
f | 56
(b)
b | 96
c | 75
d | 29
e | 61
loc includes the end label f; iloc stops before position 5.
loc slices by label (end included); iloc by position (end left out)