How to apply rotation on a loop on BGE?
A Python controller describes the operations within a single point in time (logic frame).

This means your code performs all turns at the same point in time. The render will take place after your look completed (regardless how long your loop takes).

Animations are (change) operations over time. That means your Python controller should perform a single turn, rather than all turns. You execute the controller as long as you want the animation to take place.

Example:

def rotar(obj, sentido):
velocity = 2
if velocity &lt; initialVelocity:
    obj.applyRotation((0,0, sentido*velocity), True)
    velocity = velocity/1.5
    print(obj.worldOrientation.to_euler().z)


(Replaced while with if in your sample)

Continual animation

While the above code performs the behavior of a single frame you need behavior at an higher abstraction.

E.g. you want:


when pressing a key


determine the final orientation
start turning

when the orientation reaches the final orientation


end turning

while turning


rotate on step towards the final orientation



You might discover a slight issue: what happens when the final step is too much? Means: the last step exceeds the final orientation. 

As described the object will start shaking as it turns left/right all the time.

Solutions:


stop before the final orientation is reached (it never exceeds, but
might not match the final orientation)
stop after exceeding the final orientation (it will exceed unless it hits the final orientation)
when the last step is larger than the necessary step size immediately apply the final orientation (this will always lead to the final orientation, but the steps are not necessarily of the same size).