Worksheets › Class 11 › Introduction to NumPy
Class 11 · Informatics Practices worksheetIntroduction 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.
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.
NumPy stands for:
- New Python
- Natural Python
- Number Python
- Numerical Python
Answer
(d) Numerical Python
- 2.
What does this print? import numpy as np a = np.array([72, 54, 74, 71]) print(a.ndim)
- 4
- 2
- 1
- 3
Answer
(c) 1
a flat list gives a 1-D array
- 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)
- (10,)
- (5, 2)
- (2,)
- (2, 5)
Answer
(d) (2, 5)
2 rows, 5 columns
Section B · short answer
- 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.
- 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
- 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.