Get Started

Your First NumPy Array

You're now going to dive into the world of baseball. Along the way, you'll get comfortable with the basics of numpy, a powerful package to do data science.

A list baseball has already been defined in the Python script, representing the height of some baseball players in centimeters. Can you add some code to create a numpy array from it?

This is a part of the course

“Introduction to Python”

View Course

Exercise instructions

  • Import the numpy package as np, so that you can refer to numpy with np.
  • Use np.array() to create a numpy array from baseball. Name this array np_baseball.
  • Print out the type of np_baseball to check that you got it right.

Hands-on interactive exercise

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

# Import the numpy package as np


baseball = [180, 215, 210, 210, 188, 176, 209, 200]

# Create a numpy array from baseball: np_baseball


# Print out type of np_baseball
Edit and Run Code