BuildlyBuildly
DashboardExercisesProfileHelp
Back to all

Practice: NumPy Arrays

Drills tagged with this skill, unpassed first. Pass them all to mark the skill ready for scenarios.

Module 2: Data Analytics

0/3 done
Exercises (0/3)
  • 1
    Celsius to Fahrenheit
    Context. Convert a list of Celsius temperatures to Fahrenheit in one shot — no loops. Your task. Write celsius_to_fahrenheit(celsius) that takes a list of Celsius numbers and returns a NumPy array of the matching Fahrenheit values. Formula: F = C * 9/5 + 32. Example. [0, 100] → array([32., 212.]). Notes. Use NumPy broadcasting — no for-loops. Empty input → empty array.
    7 min· 10 XP
  • 2
    Row Sums
    Context. A 2D table of weekly sales — each row is a product, each column a day of the week. You want the total per product. Your task. Write row_sums(matrix) that takes a 2D list (list of lists) and returns a NumPy array with one entry per row — the sum of that row. Example. [[1,2,3],[4,5,6]] → array([6, 15]). Notes. Use .sum() with the right axis argument. Rows with negative values still sum normally (no special-casing). A single-row input still returns a 1-element array.
    7 min· 10 XP
  • 3
    Pick Specific Columns
    Context. A wide sensor table — you only care about certain columns and want them in a specific order. Your task. Write pick_columns(matrix, cols) that takes a 2D list and a list of column indices, and returns a NumPy array with just those columns, in the order given. Example. matrix=[[1,2,3],[4,5,6]], cols=[0,2] → array([[1, 3], [4, 6]]). Notes. cols=[2,0] returns columns in that swapped order, not sorted. cols=[] returns a 2D array with 0 columns (one empty row per input row).
    7 min· 10 XP