NCA-ADS - Foundations of Accelerated Data Science - Section 5.1

Apply Python fundamentals with NumPy, pandas, and Jupyter.

Apply core Python data science tools - NumPy for array operations, pandas for tabular data, and Jupyter for interactive notebooks - as the foundation of accelerated workflows. Recognise how these libraries integrate with RAPIDS and form the base layer that cuDF and cuML replace or extend.

NumPypandasJupyter

Practice question for this objective

Free sampleFoundations of Accelerated Data Scienceeasy

A data scientist rewrites a loop that iterates over one million floating-point values in a Python list, replacing it with a NumPy array operation. Which outcome best explains the speedup?

  • ANumPy automatically distributes the loop across all available CPU cores using the threading module, which reduces wall-clock time proportionally to the core count.
  • BNumPy converts each Python integer or float to a C double before the loop begins, which reduces the cost of each individual Python type-check inside the loop body.
  • CNumPy caches the result of the first iteration and reuses it for subsequent identical values, reducing the effective number of arithmetic operations the CPU must perform.
  • DNumPy stores data in contiguous memory blocks of a single type, allowing low-level vectorised CPU instructions to process many elements at once without Python interpreter overhead per element. Correct
Explain why NumPy vectorised array operations outperform equivalent Python loops for large numeric datasets. A pure Python loop pays a Python interpreter dispatch cost for each element: boxing the value as a Python object, evaluating the loop condition, and calling the operation. NumPy arrays store elements as raw C-level numeric types in a contiguous memory block, enabling the CPU to apply SIMD vectorised instructions across many elements in a single instruction cycle with no per-element interpreter overhead. This architectural difference, rather than multithreading or caching, is the primary reason vectorised NumPy operations are orders of magnitude faster than equivalent Python loops on large arrays.

Why A is wrong: NumPy's standard array operations are single-threaded by default; the speedup comes from vectorised instructions and C-level execution, not automatic multithreading via the threading module.

Why B is wrong: While NumPy does use C-level numeric types, the benefit is eliminating the loop overhead entirely through vectorised operations, not merely reducing per-iteration type-check cost inside a continued Python loop.

Why C is wrong: NumPy does not apply memoisation or result caching across array elements; every element is processed. The performance gain is from vectorised execution, not skipping repeated computations.

Why D is correct: NumPy's homogeneous, contiguous arrays let SIMD/vectorised CPU instructions operate on batches of elements, bypassing the per-element Python object overhead that makes pure Python loops slow.

See more NCA-ADS practice questions, answers explained.

More in this domain

Back to all Foundations of Accelerated Data Science objectives, or the NCA-ADS cert hub.

Examworthy is not affiliated with or endorsed by NVIDIA. Original, blueprint-aligned practice material only.