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

Introduction to NumPy Arrays

NumPy is a powerful Python library for numerical and scientific computing, offering support for multi-dimensional arrays and various mathematical functions. It is preferred for its speed, efficient memory usage, and built-in functions, making it essential in fields like Data Science and Machine Learning. The document also outlines steps to create 2D and 3D arrays using NumPy.

Uploaded by

kartiknirmal9711
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)
2 views2 pages

Introduction to NumPy Arrays

NumPy is a powerful Python library for numerical and scientific computing, offering support for multi-dimensional arrays and various mathematical functions. It is preferred for its speed, efficient memory usage, and built-in functions, making it essential in fields like Data Science and Machine Learning. The document also outlines steps to create 2D and 3D arrays using NumPy.

Uploaded by

kartiknirmal9711
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

1.

Answer the following

1. What is NumPy? Why should we use it?

NumPy (Numerical Python) is a powerful Python library used for numerical and scientific computing. It provides
support for multi-dimensional arrays, mathematical functions, linear algebra, statistics, and more.

Why we use NumPy:

• It is faster than Python lists for numerical operations.

• Provides efficient array operations and broadcasting.

• Uses less memory compared to lists.

• Offers built-in functions for mathematics, statistics, and linear algebra.

• Widely used in Data Science, Machine Learning, and AI.

2. Steps to Create 2D and 3D Arrays (with Output)

Step 1: Import NumPy

import numpy as np

(a) Create a 2D Array

Steps:

1. Import NumPy.

2. Use [Link]() with a list of lists.

3. Print the array.

import numpy as np

arr_2d = [Link]([[1, 2, 3],

[4, 5, 6]])

print(arr_2d)

Output:

[[1 2 3]

[4 5 6]]

(b) Create a 3D Array

Steps:

1. Import NumPy.

2. Use [Link]() with a list of 2D arrays.

3. Print the array.

import numpy as np
arr_3d = [Link]([[[1, 2, 3],

[4, 5, 6]],

[[7, 8, 9],

[10, 11, 12]]])

print(arr_3d)

Output:

[[[ 1 2 3]

[ 4 5 6]]

[[ 7 8 9]

[10 11 12]]]

You might also like