Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,880 questions

51,806 answers

573 users

How to raise each element of 2D by N in Python

2 Answers

0 votes
import numpy as np
 
arr1 = np.array([[2, 4, 9, 1], [8, 5, 0, 3]])
N = 4
 
result = np.power(arr1, N)
 
print(result)
 
 
 
'''
run:
 
[[  16  256 6561    1]
 [4096  625    0   81]]

'''

 



answered Jun 17, 2023 by avibootz
0 votes
import numpy as np
 
arr1 = np.array([[2, 4, 9, 1], [8, 5, 0, 3]])
N = 4
 
result = np.float_power(arr1, N)
 
print(result)
 
 
 
'''
run:

[[1.600e+01 2.560e+02 6.561e+03 1.000e+00]
 [4.096e+03 6.250e+02 0.000e+00 8.100e+01]]

'''

 



answered Jun 17, 2023 by avibootz

Related questions

1 answer 136 views
1 answer 153 views
1 answer 179 views
1 answer 169 views
1 answer 170 views
...