</>
Skip to content
NumPy lessons (3/28)

NumPy — Get Started

First NumPy program

import numpy as np

# Create array
arr = np.array([1, 2, 3, 4, 5])
print(arr)
print(type(arr))

# Basic operations
print(arr + 10)  # Add 10 to each element
print(arr * 2)   # Multiply each element by 2
print(np.sqrt(arr))  # Square root

Array operations

arr = np.array([1, 2, 3, 4, 5])

print(f"Sum: {arr.sum()}")
print(f"Mean: {arr.mean()}")
print(f"Std: {arr.std()}")
print(f"Min: {arr.min()}")
print(f"Max: {arr.max()}")

2D arrays

arr_2d = np.array([[1, 2, 3], [4, 5, 6]])
print(arr_2d)
print(f"Shape: {arr_2d.shape}")
print(f"Size: {arr_2d.size}")

Slicing

arr = np.array([10, 20, 30, 40, 50])
print(arr[1:4])  # [20, 30, 40]
print(arr[::2])  # [10, 30, 50]

Mini Practice

  1. Create arrays
  2. Perform operations
  3. Use 2D arrays
  4. Practice slicing

Up Next

Continue with Installation - Setting up NumPy.

Related Topics

Frequently Asked Questions about Get Started

What is Get Started in NumPy?

Get Started is a fundamental concept in NumPy. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Get Started?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Get Started.

Why is Get Started important in NumPy?

Get Started is essential for NumPy development. Understanding this concept will help you write better code and solve real-world problems more effectively.