Exercises

Use IPython sessions for each exercise where practical. Each time you create or modify an array, Series or DataFrame, display the result.

  1. 7.1 (Filling arrays) Fill a 2-by-3 array with ones, a 3-by-3 array with zeros and a 2-by-5 array with 7s.

  2. 7.2 (Broadcasting) Use arange to create a 2-by-2 array containing the numbers 0–3. Use broadcasting to perform each of the following operations on the original array:

    1. Cube every element of the array.

    2. Add 7 to every element of the array.

    3. Multiply every element of the array by 2.

  3. 7.3 (Element-Wise array Multiplication) Create a 3-by-3 array containing the even integers from 2 through 18. Create a second 3-by-3 array containing the integers from 9 down to 1, then multiply the first array by the ...

Get Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.