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)

how to import numpy in python?

Back (Answer)

import numpy as np we usually assign the package to a variable named np

#2
Front (Question)

how to create a numpy array (numpy.ndarray) with 3 elements, all zeros? (assign to a variable named “a”)

Back (Answer)

a = np.zeros(3)

#3
Front (Question)

how to create a numpy array (numpy.ndarray) with 6 elements, all ones? (assign to a variable named “a”)

Back (Answer)

a = np.ones(6)

#4
Front (Question)

how to create a 2 dimensional numpy array (numpy.ndarray) with shape 6, 4 with elements all zeros? (assign to a variable named “a”)

Back (Answer)

a = np.zeros((6,4)) the parameter is a tuple!

#5
Front (Question)

how to print the variable named “v” in Jupyter to see its content?

Back (Answer)

v

#6
Front (Question)

how to print the first element of one dimensional numpy array “a” in Jupyter to see its content?

Back (Answer)

a[0]

#7
Front (Question)

how to print the type of variable “v” in Jupyter?

Back (Answer)

type(v)

#8
Front (Question)

how to print the shape of a numpy array named “a” in Jupyter?

Back (Answer)

a.shape this is the numpy.ndarray.shape function

#9
Front (Question)

how to change the shape of a numpy array named “a” in Jupyter to (4,5)?

Back (Answer)

a.shape = (4,5) with a tuple

#10
Front (Question)

how to create a one dimensional numpy array, starting with 10, ending with 30, with equally distant elements, 12 of them altogether? (assign to variable “a”)

Back (Answer)

a = np.linspace(10,30,12)

#11
Front (Question)

create a python list of 4,5,8 and immidiately convert to a numpy array and assign to a variable named “a”

Back (Answer)

a = np.array([4,5,8])

#12
Front (Question)

how to efficiently access the last element in a python list named l?

Back (Answer)

l[-1]

#13
Front (Question)

“a” array or list has 10 elements. Access the elements indexed 3,4,5

Back (Answer)

a[3:6]

#14
Front (Question)

create an array with 50 random floats, evenly distributed, from 0 to 10

Back (Answer)

a = np.random.rand(50)*10

#15
Front (Question)

create an array with 20 random integers from 0 to 10 (including 10 as a possible value)

Back (Answer)

a = np.random.randint(0,11,size=20)

#16
Front (Question)

access every second element of a list or array, starting from the first

Back (Answer)

a[::2]

#17
Front (Question)

how to return an array of booleans, indicating if numpy array “a” values are greater than 5 or not at corresponding indexes?

Back (Answer)

a > 5

#18
Front (Question)

use numpy to return mean of array “a”

Back (Answer)

np.mean(a)

#19
Front (Question)

use numpy to return standard deviation of array “a”

Back (Answer)

np.std(a)

#20
Front (Question)

use numpy to return sum of array “a”

Back (Answer)

np.sum(a)

#21
Front (Question)

use numpy to return variance of array “a”

Back (Answer)

np.var(a)

#22
Front (Question)

use numpy to return minimum of array “a” and also the index of the first occurance of it

Back (Answer)

minOfA = np.min(a) firstIndexOfMinOfA = np.argmin(a)

#23
Front (Question)

use numpy to return an array which contains the elements of array “a” that are greater than 3

Back (Answer)

a[a > 3]

#24
Front (Question)

change array “a” so that the values greater than 10 will be 5, the other will be 0

Back (Answer)

a = np.where(a > 10, 5, 0)