Get startedGet started for free

Jugadores de béisbol livianos

Para seleccionar tanto en una lista como en un array numpy en Python, puedes utilizar los corchetes:

x = [4 , 9 , 6, 3, 1]
x[1]
import numpy as np
y = np.array(x)
y[1]

Especificamente para numpy, puedes utilizar también arrays numpy booleanos:

high = y > 5
y[high]

El código que calcula el IMC de todos los jugadores de béisbol ya está incluido. ¡Sigue las instrucciones y descubre cosas interesantes de esos datos!

This exercise is part of the course

Introducción a Python

View Course

Exercise instructions

  • Crea un array numpy booleano: el elemento del array debería ser igual a Truesi el IMC del jugador correspondiente es menor a 21.Puedes utilizar el operador < para esto. Nombra el array como light.
  • Imprime el array light.
  • Imprime el array numpy que contiene todos los IMC de los jugadores de béisbol cuyo IMC es menor a 21. Utiliza light dentro de los corchetes para hacer una selección en el array bmi.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# height y weight están disponibles como listas

# Importa el paquete numpy
import numpy as np

# Calcula el IMC: bmi
np_height_m = np.array(height) * 0.0254
np_weight_kg = np.array(weight) * 0.453592
bmi = np_weight_kg / np_height_m ** 2

# Creaa el array light


# Imprime light


# Imprime el IMC de todos los jugadores de béisbol cuyo IMC es menor a 21
Edit and Run Code