Under the Sagemath cloud and Windows, I always get
[ 1 3 3 1]
[ 1 1 -1 -1]
[ 1 -1 -1 1]
[ 1 -3 3 -1]
Under the linux version, I sometimes get
[ 1 3 3 1]
[ 1 0 -3 -1]
[ 1 -3 3 1]
[ 1 -3 3 -5]
I found that when I paste the following command
q = 2
r = 2
s = 2
n = s*(r+1)
d = 3
P = matrix(ZZ, r+2, r+2, lambda u, k: Krawtchouk(r+1, q, k, u))
into sage command line, I will get
[ 1 3 3 1]
[ 1 1 -1 -1]
[ 1 -1 -1 1]
[ 1 -3 3 -1]
When I load these command from a file "***.py", I will get
[ 1 3 3 1]
[ 1 0 -3 -1]
[ 1 -3 3 1]
[ 1 -3 3 -5]