That’s close - the only thing is that the last if statement (which should check for the maximum value between the X and Y values (spd and spd, respectively) - the one that you had commented out was correct) should be the ‘last resort,’ an else statement, while another elif statement above would be for the walking animation.
Basically, if Sonic’s moving faster than 10, play the run animation. Else, if he’s moving faster than 1, play the walking animation. Else, play the standing animation. This should work:
from bge import logic
cont = logic.getCurrentController() # Get the controller running this script
obj = cont.owner # Get the object with this controller
walk = cont.actuators['WalkAction'] # The walking animation actuator
run = cont.actuators['RunAction'] # The running animation actuator
stand = cont.actuator['StandAction'] # The standing animation actuator
spd = obj.getVelocity()
movevel = max(abs(spd), abs(spd))
if movevel > 10: # Play running animation
elif movevel > 1: # Play walking animation
else: # Play standing animation
EDIT: I added a movevel variable that represents how fast he’s moving (his maximum velocity).