Completed

DataFrame — Display & Iteration

Class 12 · Informatics Practices Tue, 6 Oct 2026 9:00 PM 60s / question 15 questions · 15 marks

Questions From This Challenge

Q1mcq1 mark
What does a simple loop `for col in df:` iterate over, where df is a DataFrame?
The column labels of the DataFrame ✓
Each row as a Series
Each individual cell value
The row index labels
Q2mcq1 mark
Which method is commonly used to iterate over a DataFrame row by row, yielding an (index, Series) pair for each row?
df.iterrows() ✓
df.itercols()
df.rows()
df.walk()
Q3mcq1 mark
What does df.head(n) return for a DataFrame?
A new DataFrame containing the first n rows ✓
A new DataFrame containing the last n rows
The first n column names only
The DataFrame sorted in ascending order
Q4mcq1 mark
If a DataFrame has 10 rows and df.tail() is called with no argument, how many rows are returned by default?
5 ✓
10
1
0
Q5mcq1 mark
When a DataFrame is displayed using print(df), what is shown alongside the actual data values?
The row index labels and the column headers ✓
Only the column headers, without any index
Only raw values with no labels at all
The DataFrame's memory address
Q6mcq1 mark
In the loop `for index, row in df.iterrows():`, what does the variable row represent?
A Pandas Series containing that row's data across all columns ✓
A single scalar value from the first column
A list of column names
A new DataFrame containing just that one row
Q7mcq1 mark
Which of the following statements about df.head() is true?
It returns a new DataFrame and does not modify the original DataFrame ✓
It permanently removes all rows except the first 5 from df
It only works if df has fewer than 5 rows
It sorts the DataFrame before returning results
Q8mcq1 mark
What is the main conceptual difference between df.head() and df.tail()?
head() returns rows from the beginning of the DataFrame, while tail() returns rows from the end ✓
head() returns columns, while tail() returns rows
head() modifies the DataFrame in place, while tail() does not
There is no difference; they are aliases of the same method
Q9output1 mark
What is the output of the following code, which iterates over a DataFrame directly with a for loop?
import pandas as pd
df = pd.DataFrame({
    'Name': ['Ravi', 'Sona', 'Meera', 'Ajay'],
    'Marks': [88, 92, 75, 60]
})
for col in df:
    print(col)
Correct output: Name Marks
Q10output1 mark
What is the output of the following code, which uses iterrows() to loop over the DataFrame's rows?
import pandas as pd
df = pd.DataFrame({
    'Name': ['Ravi', 'Sona', 'Meera', 'Ajay'],
    'Marks': [88, 92, 75, 60]
})
for index, row in df.iterrows():
    print(index, row['Name'])
Correct output: 0 Ravi 1 Sona 2 Meera 3 Ajay
Q11output1 mark
What is the output of the following code?
import pandas as pd
df = pd.DataFrame({
    'Name': ['Ravi', 'Sona', 'Meera', 'Ajay'],
    'Marks': [88, 92, 75, 60]
})
print(df.head(2))
Correct output: Name Marks 0 Ravi 88 1 Sona 92
Q12output1 mark
What is the output of the following code?
import pandas as pd
df = pd.DataFrame({
    'Name': ['Ravi', 'Sona', 'Meera', 'Ajay'],
    'Marks': [88, 92, 75, 60]
})
print(df.tail(2))
Correct output: Name Marks 2 Meera 75 3 Ajay 60
Q13output1 mark
What is the output of the following code, which simply prints a small DataFrame?
import pandas as pd
df2 = pd.DataFrame({'City': ['Delhi', 'Pune'], 'Pop': [30, 10]})
print(df2)
Correct output: City Pop 0 Delhi 30 1 Pune 10
Q14output1 mark
What is the output of the following code, which prints two column values for each row using iterrows()?
import pandas as pd
df = pd.DataFrame({
    'Name': ['Ravi', 'Sona', 'Meera', 'Ajay'],
    'Marks': [88, 92, 75, 60]
})
for index, row in df.iterrows():
    print(row['Name'], row['Marks'])
Correct output: Ravi 88 Sona 92 Meera 75 Ajay 60
Q15output1 mark
What is the output of the following code, which iterates over a DataFrame's rows and prints only the names of students scoring above 80?
import pandas as pd
df = pd.DataFrame({
    'Name': ['Ravi', 'Sona', 'Meera', 'Ajay'],
    'Marks': [88, 92, 75, 60]
})
for index, row in df.iterrows():
    if row['Marks'] > 80:
        print(row['Name'])
Correct output: Ravi Sona
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...