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

Numpy Assignment

NumPy is a powerful Python library for numerical computations, providing support for large multi-dimensional arrays and efficient mathematical functions. It offers advantages such as performance, memory efficiency, convenience, vectorization, and interoperability with other libraries. NumPy is essential for data science, machine learning, and scientific computing, allowing easy creation and manipulation of arrays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Numpy Assignment

NumPy is a powerful Python library for numerical computations, providing support for large multi-dimensional arrays and efficient mathematical functions. It offers advantages such as performance, memory efficiency, convenience, vectorization, and interoperability with other libraries. NumPy is essential for data science, machine learning, and scientific computing, allowing easy creation and manipulation of arrays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

NumPy: An Overview

What is NumPy?
NumPy (Numerical Python) is a powerful library in Python used for numerical computations. It
provides support for large, multi-dimensional arrays and matrices, along with a collection of
mathematical functions to operate on these arrays efficiently.

Why Should We Use NumPy?


1. Performance: NumPy arrays are faster and more efficient than Python lists due to their optimized
C-based backend.
2. Memory Efficiency: Uses less memory compared to lists for storing large datasets.
3. Convenience: Provides built-in mathematical functions, making operations easy and concise.
4. Vectorization: Allows element-wise operations without explicit loops, enhancing speed.
5. Interoperability: Easily integrates with other Python libraries like Pandas, SciPy, and TensorFlow.

Creating 2D and 3D Arrays in NumPy

Step 1: Install and Import NumPy


import numpy as np

Step 2: Create a 2D Array


# Creating a 2D array (Matrix)
array_2d = [Link]([[1, 2, 3], [4, 5, 6]])
print("2D Array:")
print(array_2d)

Output:
2D Array:
[[1 2 3]
[4 5 6]]

Step 3: Create a 3D Array


# Creating a 3D array
array_3d = [Link]([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])
print("3D Array:")
print(array_3d)

Output:
3D Array:
[[[ 1 2 3]
[ 4 5 6]]

[[ 7 8 9]
[10 11 12]]]

Conclusion
NumPy is an essential library for handling large-scale numerical data efficiently. By using NumPy,
we can create and manipulate arrays with ease, making it an indispensable tool for data science,
machine learning, and scientific computing.

End of Assignment

You might also like