Back to marketplace

Numpy

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

What is common acronym for numpy when importing?

Back (Answer)

import numpy as np

#2
Front (Question)

What is numpy short for?

Back (Answer)

Numerical Python

#3
Front (Question)

What does numpy provide?

Back (Answer)

An efficient interface to store and operate on dense data buffers.

#4
Front (Question)

How are numpy arrays better than Python lists - 1?

Back (Answer)

NumPy arrays are like Python’s built-in list type, but NumPy arrays provide much more efficient storage and data operations as the arrays grow larger in size.

#5
Front (Question)

What is the difference between a dynamic-type list and a fixed-type (numpy style) array?

Back (Answer)

At the implementation level, the array essentially contains a single pointer to one contiguous block of data. The Python list, on the other hand, contains a pointer to a block of pointers, each of which in turn points to a full Python object

#6
Front (Question)

Can numpy arrays contain elements of mixed type?

Back (Answer)

No. All elements must be the same.

#7
Front (Question)

How do you create a fixed-type array in Python?

Back (Answer)

import array L = list(range(10)) A = array.array(‘i’, L) returns: array(‘i’, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) where ‘i’ is type code indicating integers

#8
Front (Question)

How do you create an numpy array from Python list?

Back (Answer)

np.array([1, 4, 2, 5, 3])

#9
Front (Question)

What happens when creating numpy arrays which are not of the same type?

Back (Answer)

Numpy will attempt to upcast if possible. ints upcast to floats

#10
Front (Question)

How do we explicitly set the data type of an numpy array?

Back (Answer)

np.array([1, 2, 3, 4], dtype=’float32’)

#11
Front (Question)

Is it more efficient to create a numpy array from scratch or from existing list?

Back (Answer)

From scratch - especially for larger arrays

#12
Front (Question)

Create numpy array all zeros

Back (Answer)

np.zeros(10, dtype=int) # 10 indicates 10 values

#13
Front (Question)

Create numpy array all ones

Back (Answer)

np.ones(10, dtype=int) # 10 indicates 10 values

#14
Front (Question)

Create numpy array with 1 specific value

Back (Answer)

np.full(10, 3.14, dtype=int) # 10 indicates 10 values, 3.14 is the value to include

#15
Front (Question)

Create multi-dimensional numpy array

Back (Answer)

np.zeros((3,5), dtype=float) # create a 3x5 array poulated with zeros in float type

#16
Front (Question)

What is syntax for numpy array filled with a linear sequence?

Back (Answer)

np.arange(0, 20, 2) # values from 0 up to, not including 20, step by 2

#17
Front (Question)

What is syntax for numpy array of x values equally spaced btw two values?

Back (Answer)

np.linspace(0, 1, 5) where 0 and 1 are bounding values, and 5 = x

#18
Front (Question)

How do you create a numpy array of 3x3 random ints between 0 and 10?

Back (Answer)

np.random.randint(0, 10, (3, 3))

#19
Front (Question)

What are the attributes of an numpy array, where array = x3.

Back (Answer)

x3. ndim = number of dimensions x3. shape = shape of the array x3. size = number of elements in array x3. dtype = datatype

#20
Front (Question)

How do you access the i-th element in a 1 dimensional numpy array x?

Back (Answer)

x[i] - same as for Python lists

#21
Front (Question)

How do you access the elements in a multi-dimensional numpy array x?

Back (Answer)

x[2,0] # will return 1 for below array array([[3, 5, 2, 4], [7, 6, 8, 8], [1, 6, 7, 7]])

#22
Front (Question)

How do you modify the elements in a multi-dimensional numpy array x?

Back (Answer)

x[2,0] = 12 # will set the below value 1 to 12 array([[3, 5, 2, 4], [7, 6, 8, 8], [1, 6, 7, 7]]) NB. Numpy arrays are fixed type. If you attempt to set value to a float in above array then it will be silently truncated.

#23
Front (Question)

What is numpy array slicing for 1-D arrays?

Back (Answer)

Similar to List slicing, same syntax used. x[:5] # first five elements

#24
Front (Question)

How does numpy slicing work for multi-dimensional arrays?

Back (Answer)

x2[:2, :3] # two rows, three columns array([[12, 5, 2, 4], [ 7, 6, 8, 8], [ 1, 6, 7, 7]]) returns for the above array array([[12, 5, 2], [ 7, 6, 8]])