Worksheets › Class 11 › Introduction to NumPy

Class 11 · Informatics Practices worksheet

Introduction to NumPy

CBSE Informatics Practices. Lists and arrays, np.array() from lists, ndim, shape, size, dtype and itemsize, zeros, ones and arange, element-wise arithmetic. Every sheet has 20 questions in three sections and an answer key, and the questions change every time.

Open a printable sample sheet

Sample questions

Real questions from this chapter, as the app sets them. Tap Answer to see the answer and working.

Section A · multiple choice

  1. 1.

    NumPy stands for:

    1. New Python
    2. Natural Python
    3. Number Python
    4. Numerical Python
    Answer

    (d) Numerical Python

  2. 2.

    What does this print? import numpy as np a = np.array([72, 54, 74, 71]) print(a.ndim)

    1. 4
    2. 2
    3. 1
    4. 3
    Answer

    (c) 1

    a flat list gives a 1-D array

  3. 3.

    What does this print? import numpy as np a = np.array([[87, 41, 27, 51, 33], [45, 46, 49, 96, 66]]) print(a.shape)

    1. (10,)
    2. (5, 2)
    3. (2,)
    4. (2, 5)
    Answer

    (d) (2, 5)

    2 rows, 5 columns

Section B · short answer

  1. 4.

    Give two differences between a Python list and a NumPy array.

    Answer

    A list may hold items of different types; an array holds one type. Arrays support element-wise arithmetic and use less memory; lists do not.

  2. 5.

    What does each print show? Give (a) the first line (b) the second. import numpy as np L = [5, 8, 6] A = np.array(L) print(L * 3) print(A * 3)

    Answer

    (a) [5, 8, 6, 5, 8, 6, 5, 8, 6]; (b) [15 24 18]

    a list repeats; an array multiplies each element

Section C · long answer

  1. 6.

    Explain five attributes of a NumPy array with an example for a = np.array([[2, 4, 6], [1, 3, 5]]).

    Answer

    ndim = 2 (dimensions); shape = (2, 3) (rows, columns); size = 6 (elements); dtype = an integer type (int32 or int64, depending on the system); itemsize = bytes per element (4 for int32, 8 for int64).

Fresh sheets for your child

In the app, every Introduction to NumPy sheet is new: the app remembers the questions your child has already had and leaves them out. Print the sheet as a PDF, or use notebook mode and write the answers in a notebook.

Coming soon for Android and iPhone.

More Class 11 Informatics Practices