Computer Science, asked by lakshay3521, 11 months ago

what is numpy array in python? explain it with examples​

Answers

Answered by ZunayedTIME
2

Answer:

mark brainlliest if liked my answer

Explanation:

NumPy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays.

It is the fundamental package for scientific computing with Python. It contains various features including these important ones:

A powerful N-dimensional array object

Sophisticated (broadcasting) functions

Tools for integrating C/C++ and Fortran code

Useful linear algebra, Fourier transform, and random number capabilities

Besides its obvious scientific uses, NumPy can also be used as an efficient multi-dimensional container of generic data.

Arbitrary data-types can be defined using Numpy which allows NumPy to seamlessly and speedily integrate with a wide variety of databases.

Installation:

Mac and Linux users can install NumPy via pip command:

pip install numpy

Windows does not have any package manager analogous to that in linux or mac.

Please download the pre-built windows installer for NumPy from here (according to your system configuration and Python version).

And then install the packages manually.

Note: All the examples discussed below will not run on an online IDE.

1. Arrays in NumPy: NumPy’s main object is the homogeneous multidimensional array.

It is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers.

In NumPy dimensions are called axes. The number of axes is rank.

NumPy’s array class is called ndarray. It is also known by the alias array.

Example :

[[ 1, 2, 3],

[ 4, 2, 5]]

Here,

rank = 2 (as it is 2-dimensional or it has 2 axes)

first dimension(axis) length = 2, second dimension has length = 3

overall shape can be expressed as: (2, 3)

filter_none

edit

play_arrow

brightness_4

# Python program to demonstrate  

# basic array characteristics  

import numpy as np  

 

# Creating array object  

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

                [ 4, 2, 5]] )  

 

# Printing type of arr object  

print("Array is of type: ", type(arr))  

 

# Printing array dimensions (axes)  

print("No. of dimensions: ", arr.ndim)  

 

# Printing shape of array  

print("Shape of array: ", arr.shape)  

 

# Printing size (total number of elements) of array  

print("Size of array: ", arr.size)  

 

# Printing type of elements in array  

print("Array stores elements of type: ", arr.dtype)  

Output :

Array is of type:  

No. of dimensions:  2

Shape of array:  (2, 3)

Size of array:  6

Array stores elements of type:  int64

Similar questions