numpy.asscalar() in Python Last Updated : 28 Nov, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report numpy.asscalar() function is used when we want to convert an array of size 1 to its scalar equivalent. Syntax : numpy.asscalar(arr) Parameters : arr : [ndarray] Input array of size 1. Return : Scalar representation of arr. The output data type is the same type returned by the input’s item method. Code #1 : Working Python # Python program explaining # numpy.asscalar() function import numpy as geek # creating a array of size 1 in_arr = geek.array([ 8 ]) print ("Input array : ", in_arr) out_scalar = geek.asscalar(in_arr) print ("output scalar from input array : ", out_scalar) Output : Input array : [8] output scalar from input array : 8 Code #2 : Python # Python program explaining # numpy.asscalar() function import numpy as geek in_list = [2 ] # changing the list to size 1 array arr = geek.array(in_list) print ("Input array from list : ", arr) # changing the array to scalar scalar = geek.asscalar(arr) print ("output scalar from input list : ", scalar) Output : Input array from list : [2] output scalar from input list : 2 Comment More infoAdvertise with us Next Article NumPy Array in Python J jana_sayantan Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads numpy.asarray() in Python numpy.asarray()function is used when we want to convert input to an array. Input can be lists, lists of tuples, tuples, tuples of tuples, tuples of lists and arrays. Syntax : numpy.asarray(arr, dtype=None, order=None) Parameters : arr : [array_like] Input data, in any form that can be converted to a 2 min read numpy.asanyarray() in Python numpy.asanyarray()function is used when we want to convert input to an array but it pass ndarray subclasses through. Input can be scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays. Syntax : numpy.asanyarray(arr, dtype=None, order=None) Parameters : arr : [array_ 2 min read numpy.isscalar() in Python In this article, we will elucidate the `numpy.isscalar()` function through a well-documented code example and comprehensive explanation. Python numpy.isscalar() Syntax Syntax : numpy.isscalar(element) Parameters: element: The input element to be checked for scalar properties.Return Type: bool: Retur 3 min read numpy.alen() in Python numpy.alen() function is used to return the length of the first dimension of the input array. Syntax : numpy.alen(arr) Parameters : arr : [array_like] Input array. Return : [int]Length of the first dimension of arr. Code #1 : Python3 # Python program explaining # alen() function import numpy as geek 1 min read NumPy Array in Python NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C 2 min read numpy.add() in Python NumPy, the Python powerhouse for scientific computing, provides an array of tools to efficiently manipulate and analyze data. Among its key functionalities lies numpy.add() a potent function that performs element-wise addition on NumPy arrays. numpy.add() SyntaxSyntax :Â numpy.add(arr1, arr2, /, out= 4 min read Like