- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Return the bases when first array elements are raised to powers from second array in Python

To return the bases when first array elements are raised to powers from second array, use the float_power() method in Python Numpy. The method returns the bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars. The parameter x1 are the bases. The parameter x2 are the exponents.

Raise each base in x1 to the positionally-corresponding power in x2. x1 and x2 must be broadcastable to the same shape. This differs from the power function in that integers, float16, and float32 are promoted to floats with a minimum precision of float64 so that the result is always inexact. The intent is that the function will return a usable result for negative powers and seldom overflow for positive powers.

Negative values raised to a non-integral value will return nan. To get complex results, cast the input to complex, or specify the dtype to be complex

## Steps

At first, import the required libraries −

import numpy as np

The bases −

x1 = range(6)

Display the bases −

print("The bases...\n",x1)

To return the bases when first array elements are raised to powers from second array, use the float_power() method in Python Numpy. The method returns the bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars −

print("\nResult...\n",np.float_power(x1, 2))

## Example

import numpy as np # The bases x1 = range(6) # Display the bases print("The bases...\n",x1) # To return the bases when first array elements are raised to powers from second array, use the float_power() method in Python Numpy print("\nResult...\n",np.float_power(x1, 2))

## Output

The bases... range(0, 6) Result... [ 0. 1. 4. 9. 16. 25.]

- Related Questions & Answers
- Set the first array elements raised to powers from second array element-wise in Numpy
- Return element-wise base masked array raised to power from second array in Numpy
- Subtracting array in JavaScript Delete all those elements from the first array that are also included in the second array
- Sort the second array according to the elements of the first array in JavaScript
- Find elements which are present in first array and not in second in C++
- Return the bases to different exponents in Python
- Find the first, second and third minimum elements in an array in C++
- Maximize first array over second in JavaScript
- Count elements present in first array but not in second in C++
- Return the first duplicate number from an array in JavaScript
- Difference between first and the second array in JavaScript
- Find the first, second and third minimum elements in an array in C++ program
- Return Top two elements from array JavaScript
- Elements present in first array and not in second using STL in C++
- Return the sum of two consecutive elements from the original array in JavaScript