Nearly right ;).
You run scripts by entering the filename
You can’t run modules, but you call members/functions of the module. So you write the moduleName.functionName.
In this case when you called your file speed.py:
without the () as you would do when calling from Python code.
If you have another filename than use this name without the .py part. If it has no .py it can’t be recognised as module.
The BGE does something like this for you already:
moduleName.functionName( currentController )
it is BU/s
because 1 BU = 1 meter you can assume it is m/s.
You could do it by yourself, by storing the position of the object. At the next tick you calculate the difference between the new position and the old one. Than you divide this by the time since you stored the last position.
But it is much easier to use getLinearVelocity().
your script calculates a part of the speed which is projected on the X axis. This is not necessarily the right speed as the object might move up/down or left/right. These motion will be ignored when you look at one axis only. But in certain situations this can be the value that you want. Especially if you want to see negative speed.
The speed value is the length of the velocity vector.
The length of a vector is sqrt(x^2+y^2+z^2) which is already provided by vector.magnitude ;).
I hope it helps