Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i pass a numpy array as an argument to a function, just like a variable?

Am looking to pass numpy arrays as arguments to a function? How is this done? Can i simply pass it like variables as shown below?

def force(x,y,z):
     for i in range(N):
        for j in range(i+1,N,1):
            xij=x[i]-x[j]
            yij=y[i]-y[j]
            zij=z[i]-z[j]
like image 663
user42836 Avatar asked Feb 04 '26 12:02

user42836


1 Answers

Python is a dynamic language, meaning there is no type checking done during compilation. You can pass anything into a function.

like image 103
Jim Aho Avatar answered Feb 07 '26 03:02

Jim Aho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!