Some snakes are just like that mate.
But it could be a number of things...
If its just a snappy snake, i dont think there is much you can do, but if the snake is hungry and thinks your hand is food, thats a different story.... Just make sure its not hungry before handling
How old and what size is your carpet? Also what are you feeding it?
Bill.