Controlling a text object through python. Hooking it to an internal variable
When trying to execute your code, I get the error:

KX_GameObject, key "x" does not exist


Replace all your T['x'] with another objects property such as:

T.localPosition.x


If this isn't the property you want, you can search the objects fields with:

print(dir(T))


You have to parse/cast the int to a string with the python str() method.
The last line compiles fine as:

if T.localPosition.x  == 3:
    T.text = str(T.localPosition.x)