0% found this document useful (0 votes)
4 views2 pages

Awp Assign 1

NumPy is a powerful library for numerical computing in Python, providing support for large multi-dimensional arrays and optimized mathematical functions. It is efficient for storing and manipulating datasets, supports fast operations, and is compatible with various scientific libraries. The document also includes steps to create 2D and 3D arrays using NumPy, demonstrating their structure and output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Awp Assign 1

NumPy is a powerful library for numerical computing in Python, providing support for large multi-dimensional arrays and optimized mathematical functions. It is efficient for storing and manipulating datasets, supports fast operations, and is compatible with various scientific libraries. The document also includes steps to create 2D and 3D arrays using NumPy, demonstrating their structure and output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

[Link] is NumPy?

NumPy (Numerical Python) is a powerful library for numerical computing in Python. It provides
support for large, multi-dimensional arrays and matrices, along with a wide variety of
mathematical functions to operate on these arrays. NumPy is widely used in scientific
computing, data analysis, machine learning, and other areas that require efficient numerical
computation.

Why should we use NumPy?

1. Efficient storage and manipulation of large datasets: NumPy arrays are more
efficient than Python's built-in lists for storing and manipulating numerical data.
2. Fast mathematical operations: NumPy offers optimized mathematical functions that
allow for fast element-wise operations on arrays.
3. Support for multi-dimensional arrays: It allows you to work with both 2D and higher-
dimensional arrays, essential for tasks like image processing and machine learning.
4. Compatibility with other libraries: Many scientific and machine learning libraries (such
as SciPy, pandas, TensorFlow, etc.) are built to work seamlessly with NumPy arrays.

[Link] the steps to create 2D, and 3D array with output.


1. Creating a 2D Array

A 2D array is essentially a matrix (a table with rows and columns).

import numpy as np

# Create a 2D array (3 rows, 4 columns)


array_2d = [Link]([[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]])

print("2D Array:")
print(array_2d)

Output:

2D Array:
[[ 1 2 3 4]
[ 5 6 7 8]
[ 9 10 11 12]]

2. Creating a 3D Array
A 3D array can be thought of as a stack of matrices, or a cube-like structure, with multiple 2D
arrays.

# Create a 3D array (2 layers, 3 rows, 4 columns)


array_3d = [Link]([[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]],

[[13, 14, 15, 16],


[17, 18, 19, 20],
[21, 22, 23, 24]]])

print("3D Array:")
print(array_3d)

Output:

3D Array:
[[[ 1 2 3 4]
[ 5 6 7 8]
[ 9 10 11 12]]

[[13 14 15 16]
[17 18 19 20]
[21 22 23 24]]]

Summary:
● 2D array: A matrix with rows and columns.
● 3D array: A collection of 2D arrays stacked on top of each other, representing a higher-
dimensional structure.

Both arrays can be created using [Link]() and can represent a wide variety of data
structures in numerical computing.

You might also like