1-D Arrays
A one-dimensional array is a collection of elements, all of the same type, indexed by sequences of natural numbers.
Let's have a look at an example of creating a 1-D array:
1234567import numpy as np # Creating array arr = np.array([1, 2, 0, 0]) # Displaying array print(arr)
Note
We should use the
np.array()
function and enclose your 1-dimensional array in square brackets. For example:np.array([value1, value2, value3])
.
Takk for tilbakemeldingene dine!
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 4.76
1-D Arrays
Sveip for å vise menyen
A one-dimensional array is a collection of elements, all of the same type, indexed by sequences of natural numbers.
Let's have a look at an example of creating a 1-D array:
1234567import numpy as np # Creating array arr = np.array([1, 2, 0, 0]) # Displaying array print(arr)
Note
We should use the
np.array()
function and enclose your 1-dimensional array in square brackets. For example:np.array([value1, value2, value3])
.
Takk for tilbakemeldingene dine!