Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Function array() | Getting Started with NumPy
NumPy in a Nutshell
course content

Contenido del Curso

NumPy in a Nutshell

NumPy in a Nutshell

1. Getting Started with NumPy
2. Dimensions in Arrays
3. Indexing and Slicing
4. Important Functions

Function array()

In fact, there are various functions in NumPy for creating arrays. Now, we'll explore one of the most commonly used ones, namely np.array(). Below, you'll find an example of how to use this function:

12345678
# Importing NumPy import numpy as np # Creating array arr = np.array([1, 3, 5, 7, 9, 11, 13]) # Displaying array print(arr)
copy

Let's now determine the type of object that this function creates. We can do this using the well-known function type().

Note

The type() function takes an object of any type and returns its type. The argument can indeed be of any type: number, string, list, dictionary, tuple, function, class, module, etc.

12345678
import numpy as np arr = np.array([1, 3, 5, 7, 9, 11, 13]) # Displaying array print(arr) # Displaying the type of created array print(type(arr))
copy

We can see the type of the created array is ndarray. But what does that mean? ndarray - This object is a multidimensional homogeneous array with a predetermined number of elements.

Now it's time to practice!

Tarea

  1. You have to create two NumPy arrays. The first one should look like this: [65, 2, 89, 5, 0, 1] and the second one should look like this: [1, 2, 3].
  2. Display these arrays on the screen.
  3. Display the type of these arrays on the screen.

Tarea

  1. You have to create two NumPy arrays. The first one should look like this: [65, 2, 89, 5, 0, 1] and the second one should look like this: [1, 2, 3].
  2. Display these arrays on the screen.
  3. Display the type of these arrays on the screen.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 1. Capítulo 2
toggle bottom row

Function array()

In fact, there are various functions in NumPy for creating arrays. Now, we'll explore one of the most commonly used ones, namely np.array(). Below, you'll find an example of how to use this function:

12345678
# Importing NumPy import numpy as np # Creating array arr = np.array([1, 3, 5, 7, 9, 11, 13]) # Displaying array print(arr)
copy

Let's now determine the type of object that this function creates. We can do this using the well-known function type().

Note

The type() function takes an object of any type and returns its type. The argument can indeed be of any type: number, string, list, dictionary, tuple, function, class, module, etc.

12345678
import numpy as np arr = np.array([1, 3, 5, 7, 9, 11, 13]) # Displaying array print(arr) # Displaying the type of created array print(type(arr))
copy

We can see the type of the created array is ndarray. But what does that mean? ndarray - This object is a multidimensional homogeneous array with a predetermined number of elements.

Now it's time to practice!

Tarea

  1. You have to create two NumPy arrays. The first one should look like this: [65, 2, 89, 5, 0, 1] and the second one should look like this: [1, 2, 3].
  2. Display these arrays on the screen.
  3. Display the type of these arrays on the screen.

Tarea

  1. You have to create two NumPy arrays. The first one should look like this: [65, 2, 89, 5, 0, 1] and the second one should look like this: [1, 2, 3].
  2. Display these arrays on the screen.
  3. Display the type of these arrays on the screen.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 1. Capítulo 2
toggle bottom row

Function array()

In fact, there are various functions in NumPy for creating arrays. Now, we'll explore one of the most commonly used ones, namely np.array(). Below, you'll find an example of how to use this function:

12345678
# Importing NumPy import numpy as np # Creating array arr = np.array([1, 3, 5, 7, 9, 11, 13]) # Displaying array print(arr)
copy

Let's now determine the type of object that this function creates. We can do this using the well-known function type().

Note

The type() function takes an object of any type and returns its type. The argument can indeed be of any type: number, string, list, dictionary, tuple, function, class, module, etc.

12345678
import numpy as np arr = np.array([1, 3, 5, 7, 9, 11, 13]) # Displaying array print(arr) # Displaying the type of created array print(type(arr))
copy

We can see the type of the created array is ndarray. But what does that mean? ndarray - This object is a multidimensional homogeneous array with a predetermined number of elements.

Now it's time to practice!

Tarea

  1. You have to create two NumPy arrays. The first one should look like this: [65, 2, 89, 5, 0, 1] and the second one should look like this: [1, 2, 3].
  2. Display these arrays on the screen.
  3. Display the type of these arrays on the screen.

Tarea

  1. You have to create two NumPy arrays. The first one should look like this: [65, 2, 89, 5, 0, 1] and the second one should look like this: [1, 2, 3].
  2. Display these arrays on the screen.
  3. Display the type of these arrays on the screen.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

In fact, there are various functions in NumPy for creating arrays. Now, we'll explore one of the most commonly used ones, namely np.array(). Below, you'll find an example of how to use this function:

12345678
# Importing NumPy import numpy as np # Creating array arr = np.array([1, 3, 5, 7, 9, 11, 13]) # Displaying array print(arr)
copy

Let's now determine the type of object that this function creates. We can do this using the well-known function type().

Note

The type() function takes an object of any type and returns its type. The argument can indeed be of any type: number, string, list, dictionary, tuple, function, class, module, etc.

12345678
import numpy as np arr = np.array([1, 3, 5, 7, 9, 11, 13]) # Displaying array print(arr) # Displaying the type of created array print(type(arr))
copy

We can see the type of the created array is ndarray. But what does that mean? ndarray - This object is a multidimensional homogeneous array with a predetermined number of elements.

Now it's time to practice!

Tarea

  1. You have to create two NumPy arrays. The first one should look like this: [65, 2, 89, 5, 0, 1] and the second one should look like this: [1, 2, 3].
  2. Display these arrays on the screen.
  3. Display the type of these arrays on the screen.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 1. Capítulo 2
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt