numpy.float_power() in Python Last Updated : 29 Nov, 2018 Comments Improve Suggest changes Like Article Like Report numpy.float_power(arr1, arr2, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : Array element from first array is raised to the power of element from second element(all happens element-wise). Both arr1 and arr2 must have same shape. float_power differs from the power function in that integers, float16, and float32 are promoted to floats with a minimum precision of float64 such that result is always inexact. This function will return a usable result for negative powers and seldom overflow for +ve powers. Parameters : arr1 : [array_like]Input array or object which works as base. arr2 : [array_like]Input array or object which works as exponent. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions(ufunc) at that position, False value means to leave the value in the output alone. Return : An array with elements of arr1 raised to exponents in arr2 Code 1 : arr1 raised to arr2 Python # Python program explaining # float_power() function import numpy as np # input_array arr1 = [2, 2, 2, 2, 2] arr2 = [2, 3, 4, 5, 6] print ("arr1 : ", arr1) print ("arr1 : ", arr2) # output_array out = np.float_power(arr1, arr2) print ("\nOutput array : ", out) Output : arr1 : [2, 2, 2, 2, 2] arr1 : [2, 3, 4, 5, 6] Output array : [ 4. 8. 16. 32. 64.] Code 2 : elements of arr1 raised to exponent 2 Python # Python program explaining # float_power() function import numpy as np # input_array arr1 = np.arange(8) exponent = 2 print ("arr1 : ", arr1) # output_array out = np.float_power(arr1, exponent) print ("\nOutput array : ", out) Output : arr1 : [0 1 2 3 4 5 6 7] Output array : [ 0. 1. 4. 9. 16. 25. 36. 49.] Code 3 : float_power handling results if arr2 has -ve elements Python # Python program explaining # float_power() function import numpy as np # input_array arr1 = [2, 2, 2, 2, 2] arr2 = [2, -3, 4, -5, 6] print ("arr1 : ", arr1) print ("arr2 : ", arr2) # output_array out = np.float_power(arr1, arr2) print ("\nOutput array : ", out) Output : arr1 : [2, 2, 2, 2, 2] arr2 : [2, -3, 4, -5, 6] Output array : [ 4.00000000e+00 1.25000000e-01 1.60000000e+01 3.12500000e-02 6.40000000e+01] References : https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.float_power.html#numpy.float_power . Comment More infoAdvertise with us Next Article numpy.float_power() in Python mohit gupta_omg :) Follow Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Practice Tags : python Similar Reads numpy.power() in Python numpy.power(arr1, arr2, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : Array element from first array is raised to the power of element from second element(all happens element-wise). Both arr1 and arr2 must have same shape and each element in arr1 must be raised to cor 3 min read numpy.floor() in Python The numpy.floor() function returns the largest integer less than or equal to each element in the input array. It effectively rounds numbers down to the nearest whole number. Let's understand with an example:Pythonimport numpy as np a = [0.5, 1.5, 2.5, 3, 4.5, 10.1] res = np.floor(a) print("Floored:" 1 min read numpy.fabs() in Python numpy.fabs() function is used to compute the absolute values element-wise. This function returns the absolute values (positive magnitude) of the data in arr. It always return absolute values in floats. Syntax : numpy.fabs(arr, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, u 2 min read numpy.random.power() in Python With the help of numpy.random.power() method, we can get the random samples from power distribution and return the random samples by using this method. power distribution Syntax : numpy.random.power(a, size=None) Return : Return the random samples as numpy array. Example #1 : In this example we can 1 min read float() in Python Python float() function is used to return a floating-point number from a number or a string representation of a numeric value. Example: Here is a simple example of the Python float() function which takes an integer as the parameter and returns its float value. Python3 # convert integer value to floa 3 min read Python | Numpy numpy.ndarray.__pow__() With the help of Numpy numpy.ndarray.__pow__() method, we will get all the elements powered with the value that is provided as a parameter in numpy.ndarray.__pow__() method. Syntax: ndarray.__pow__($self, value, mod=None, /) Return: pow(self, value, mod) Example #1 : In this example we can see that 1 min read numpy.exp() in Python numpy.exp(array, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : This mathematical function helps user to calculate exponential of all the elements in the input array. Parameters : array : [array_like]Input array or object whose elements, we need to test. out : [ndarray 4 min read Numpy MaskedArray.power() function | Python numpy.MaskedArray.power() function is used to compute element-wise base array raised to power from second array. It raise each base in arr1 to the positionally-corresponding power in arr2. arr1 and arr2 must be broadcastable to the same shape. Note that an integer type raised to a negative integer p 2 min read Format a Number Width in Python Formatting numbers to a fixed width is a common requirement in various programming tasks, especially when dealing with data presentation or storage. By understanding these techniques, developers can ensure consistent and visually appealing formatting of numerical data in their Python. Format a Numbe 3 min read numpy.exp2() in Python numpy.exp2(array, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : This mathematical function helps user to calculate 2**x for all x being the array elements. Parameters : array : [array_like]Input array or object whose elements, we need to test. out : [ndarray, optional 2 min read Like