NumPy Introduction

What NumPy is and why it is fast.

✍️ 3 exercises + code challenge in this lesson

NumPy (Numerical Python) provides the ndarray: a fast, memory-efficient array for numbers. Libraries like pandas, scikit-learn and TensorFlow are built on it.

  • NumPy arrays are up to 50× faster than Python lists for maths.
  • Operations apply to every element at once (vectorisation), without loops.

Import it with the standard alias: import numpy as np. Install locally with pip install numpy.

The first run loads NumPy in your browser, which takes a few seconds.

Key Takeaways: NumPy Introduction

Mastering NumPy Introduction helps you write clean and reliable NumPy code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

NumPy Introduction Code Example

NumPy
import numpy as np

arr = np.array([1, 2, 3, 4, 5])
print(arr)
print(arr * 10)
print(type(arr))
Output
[1 2 3 4 5]
[10 20 30 40 50]
<class 'numpy.ndarray'>
Free sign-in required · Google login available

NumPy Introduction Practice Exercises

Check what you learned in “NumPy Introduction”.

/ 3 solved
Fill in the blank

Import NumPy with its standard alias.

import numpy  np
✓ Correct! Not quite. Try again.
Multiple choice

What is the main NumPy object?

✓ Correct! Not quite. Try again.
Code challenge

Create an array of [1, 2, 3, 4] and print its sum.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services