python - Why am I getting the return value of None and what does it mean? -
i no understand well, result: "none". trying start elimination (gauss) code, receive result: "none".
from numpy import * a= array([[1,0],[0,2]]) b= array([1,4]) def gauss(a,b): n=len(b) k=0 while k in range (0, n-1): i=k+1 while in range ((k+1),(n)): a[i,k]=a[i,k]/a[k,k] j=k+1 while j in range ((k+1),(n)): a[i,j]=a[i,j]-a[i,k]*a[i,k] j=j+1 b[i]=b[i]-a[i,k]*b[k] i=i+1 k=k+1 return return b print gauss(a,b)
by default, functions in python return none
if there no return
statement, or not return value. in case, add return a, b
end of function. result gauss(a, b)
return tuple (a, b)
newly computed values.
from numpy import * a= array([[1,0],[0,2]]) b= array([1,4]) def gauss(a,b): n=len(b) k=0 while k in range (0, n-1): i=k+1 while in range ((k+1),(n)): a[i,k]=a[i,k]/a[k,k] j=k+1 while j in range ((k+1),(n)): a[i,j]=a[i,j]-a[i,k]*a[i,k] j=j+1 b[i]=b[i]-a[i,k]*b[k] i=i+1 k=k+1 return a, b print gauss(a,b)
Comments
Post a Comment