Completed

Pandas Data Handling & Analysis Challenge

Class 12 · Informatics Practices Sat, 12 Sep 2026 3:00 PM 60s / question 15 questions · 15 marks

Questions From This Challenge

Q1output1 mark
What will be the output of the following Python code?
import pandas as pd

s = pd.Series([10, 20, 30, 40], index=['a', 'b', 'c', 'd'])
res = s['a':'c'].sum() - s[0:2].sum()
print(res)
Correct output: 30
Q2output1 mark
What will be the output of the following Python code?
import pandas as pd

s = pd.Series({'x': 10, 'y': 20, 'z': 30}, index=['z', 'y', 'w'])
print(s['z'] * 2)
print(s.isna().sum())
Correct output: 20.0 1
Q3output1 mark
What will be the output of the following Python code?
import pandas as pd

s = pd.Series([5, 10, 15, 20], index=['a', 'b', 'c', 'd'])
s[s > 10] = s * 2
print(s.tolist())
Correct output: [5, 10, 30, 40]
Q4output1 mark
What will be the output of the following Python code?
import pandas as pd

s1 = pd.Series([10, 20], index=['a', 'b'])
s2 = pd.Series([5, 10], index=['b', 'c'])

res = s1.add(s2, fill_value=0)
print(res['b'] + res['c'])
Correct output: 40.0
Q5mcq1 mark
Consider the following Python code: import pandas as pd s = pd.Series([10, 20, 30]) result = s.head(2) + s.tail(2) print(result.tolist()) What will be printed?
[NaN, 40.0, 30.0] ✓
[10.0, 40.0, 30.0]
[NaN, 40.0]
[NaN, 20.0, NaN]
Q6output1 mark
What will be the output of the following Python code?
import pandas as pd

s = pd.Series([1, 2, 3, 4], index=['a', 'b', 'c', 'd'])

print(s.loc['c':'a':-1].tolist())
Correct output: [3, 2, 1]
Q7output1 mark
What will be the output of the following Python code?
import pandas as pd

s1 = pd.Series([10, 20], index=['A', 'B'])
df = pd.DataFrame({'Col1': s1, 'Col2': 5})

print(df.loc['B', 'Col2'] + df.loc['A', 'Col1'])
Correct output: 15
Q8output1 mark
What will be the output of the following Python code?
import pandas as pd

data = [{'A': 1, 'B': 2}, {'A': 3, 'C': 4}]
df = pd.DataFrame(data, index=['X', 'Y'])

print(df.size)
print(df.count().sum())
Correct output: 6 4
Q9output1 mark
Consider the following DataFrame:
import pandas as pd

df = pd.DataFrame({
    'Name': ['A', 'B', 'C', 'D'],
    'Marks': [45, 75, 35, 85]
})

result = df[(df['Marks'] >= 40) & (df['Marks'] < 80)]

print(result['Name'].tolist())
Correct output: ['A', 'B']
Q10output1 mark
What will be the output of the following Python code?
import pandas as pd

df = pd.DataFrame({'Val1': [10, 20, 30]})
df['Val2'] = df['Val1'] // 3
df.loc[1, 'Val2'] = 100

print(df['Val2'].tolist())
Correct output: [3, 100, 10]
Q11output1 mark
Consider the following DataFrame:
import pandas as pd

df = pd.DataFrame({
    'A': [1, 2, 3],
    'B': [4, 5, 6]
}, index=['x', 'y', 'z'])

df = df.drop(['x', 'z'], axis=0)

print(df.shape)
Correct output: (1, 2)
Q12output1 mark
What will be the output of the following Python code?
import pandas as pd

df = pd.DataFrame({'Col1': [10, 20]}, index=['a', 'b'])
df.rename(columns={'Col1': 'Val'}, index={'a': 'x'}, inplace=True)

print(df.index[0] + str(df.columns[0]))
Correct output: xVal
Q13output1 mark
Consider the following DataFrame:
import pandas as pd

df = pd.DataFrame({
    'X': [1, 2, 3, 4]
}, index=[10, 20, 30, 40])

a = df.loc[10:30, 'X'].sum()
b = df.iloc[0:2, 0].sum()

print(a, b)
Correct output: 6 3
Q14output1 mark
What will be the output of the following Python code?
import pandas as pd

df = pd.DataFrame({
    'A': [1, 2],
    'B': [3, 4]
})

res = ""

for i, row in df.iterrows():
    res += str(row['A'])

print(res)
Correct output: 12
Q15mcq1 mark
A CSV file named "data.csv" contains 10 rows of data, excluding the header row. Which of the following pandas statements correctly reads ONLY the first 5 rows of data into a DataFrame?
df = pd.read_csv("data.csv", nrows=5) ✓
df = pd.read_csv("data.csv", head=5)
df = pd.read_csv("data.csv").iloc[1:5]
df = pd.read_csv("data.csv", skipfooter=5)
Next Live Challenge
Network Types
Class 12 · Informatics Practices Fri, 23 Oct 2026, 9:00 PM
View Live Challenges →

← Back to Live Challenge History · Practice MCQs

CodeBuddy
Hi there! 👋 I'm CodeBuddy, your KV Coders assistant.

To help me give you the most accurate answers, please select your class and subject below, or just type your question!
Buddy is typing...