change force

If a sphere bounces into a wall,

How can the force be changed to the opposite direction to a random interval with a limit?

beginner here so logic bricks if possible. python is ok too.