NumPy for Machine Learning

26 / 32

Numpy - Mathematical Operations on NumPy Arrays - Exponents

Exponents

We can find the exponent of each element of a NumPy array in a below-mentioned way. Its applied element-wise.

e.g.

import numpy as np
R_exp = np.array( [ 20, 30, 40, 50] )
S_exp = np.arange( 1, 5 )

T_exp = R_exp ** S_exp 

print(R_exp)
array([ 20, 30, 40, 50 ])

print(S_exp)
array( [ 1, 2, 3, 4 ] )

print(T_exp)

Output will be

array([ 20, 900, 64000, 6250000 ] )
INSTRUCTIONS

Please follow the below steps:

(1) Please import the required libraries

import numpy as np

(2) Please create two NumPy arrays - R_exp and S_exp - as shown below

R_exp = np.array([ [ 4, 2], [3, 4 ] ] )
S_exp = np.array( [ [2, 10], [4, 5] ] )

(3) Apply the exponent operator ** between the above created NumPy arrays R_exp and S_exp and store the result in a variable T_exp

<<your code comes here>> = R_exp  << your code comes here>> S_exp

(4) Print the array T_exp to see its values

print(<<your code comes here>>)
See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...