This document details my learnings on how to use the NumPy library for numerical computing in Python. It covers array creation, manipulation, and various mathematical operations. The document provides detailed explanations and code examples to illustrate the concepts and techniques learned. (”numpy is for mathematical purposes ”)


🔧 1. Setting Up the Environment

✅ Importing NumPy:

To use NumPy, import the library using the alias np.

import numpy as np

➕ 2. Array Creation

✅ Creating Arrays from Lists:

Convert a Python list to a NumPy array using np.array().

my_list = [1, 2, 3]
np.array(my_list)

✅ Creating Matrices:

Convert a list of lists to a 2D array (matrix).

my_matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
x = np.array(my_matrix)

📏 3. Array Attributes

✅ Shape of an Array:

Use .shape to get the dimensions of an array.

x.shape  # returns (3, 3) for a 3x3 matrix