Courseiva
Question 167 of 986
Data AnalysiseasyMultiple ChoiceObjective-mapped

DA0-002 Data Analysis Practice Question

Exhibit

Refer to the exhibit.

import pandas as pd
df = pd.read_csv('data.csv')
df['total'] = df['price'] * df['quantity']
df.head()

A data analyst runs the Python code shown. What is the result of executing this code?

⚠ Common exam trap

Test-takers frequently think `head()` shows all rows or that adding a column with an existing name throws an error, but pandas silently overwrites the column.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

It reads the data, adds a calculated column, and shows the first 5 rows

The code reads a CSV file into a pandas DataFrame, then creates a new column 'total' by summing columns 'col1' and 'col2'. Finally, `head()` returns the first 5 rows. Option A correctly describes this sequence of operations.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • It reads the data, adds a calculated column, and shows the first 5 rows

    Why this is correct

    The code does exactly that.

  • It throws an error because 'total' column already exists

    Why it's wrong here

    If column exists, it would be overwritten; no error.

  • It reads the data and displays all rows

    Why it's wrong here

    head() displays only first 5 rows.

  • It reads the data and displays summary statistics

    Why it's wrong here

    head() does not produce summary statistics.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 24, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This DA0-002 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DA0-002 exam.