Generally animals can sense fear, so they react to that fear... some animals can just be moody.
Please, give me a break, this is a reptile not a dog!
I don't ever post, I just like to read what fellow herps are up to, BUT i can see you are after some sensible advice to a common enough problem.
Your snake feels threatened, (it cannot sense
your fear) and as a result tries to defend itself the only way it knows how.
It can be calmed down though persistance, taking a few bites, showing the snake that it's efforts to intimidate you (through it's bites) are to no avail and reinforcing to it, that you are not a threat. A snake of that size 40cm (approx 4-6 months old depending on how it has been fed), does not have that big a set of teeth, you'll be right a pin prick and drop of blood at most.
A tip don't pull back when it does bite you, for 2 reasons, 1: you can injure the snakes immature teeth and 2 as described above.
There has been some helpful advice ie using a hook to remove the snake, this then gets the snake used to the routine of being removed by hook and therefore handling time. Another method is to place your hand in the vivarium with a "high 5" gesture, the snake will strike but will hit the tough palm of your hand and "usually" not able to get a hold, after it has done that a few times it will settle down and flick it's tongue to smell you. After awhile of this, slide your hand under it's head moving down to it's belly, it may move onto your hand or may need a gentle coax by touching it's tail with your other hand. When it is on your hand always support it's body and let it slide through your hand, but never constrict it as it will feel threatened again and bite. Let it settle down and just hold it, increase the time frame each day, from a couple of minutes at first, soon (hopefully) it will associate you as non-threatening form and you will be able to pick it up with ease. I have broken the snappiest of jungles by using these methods, although all animals are different, but you should be right with persistence and repitition.
Feeding, personally I would recommend once a week with the appropriate size rat/mouse. Don't handle your snake before 24hrs after feeding, I leave mine for 2 days at that age. If you feed it as much as has been suggested, twice a week, 2 rats or whatever, you will never be able to hold it, it takes a couple of days for a snake to digest it's food, more if it's abig feed, all it wants is to bask and get it's metabolism working, you picking it up after a feed, while it wants to digest, only stresses it out which is totally defeating the purpose as to why you started this thread, "MY SNAKE BITES".
Hope this is helpful.
Regards
Scott.