Purple in that situation that's where zero tolerance fails and pastoral care is required. It needs a whole school ethos of recognition that behaviour is communication.
So when the student comes in defensive because their anxious you should employ the tactics of "you talk and I'll listen" of giving choice and a get out. Of recognising the behaviour is part of a bigger picture.
That's not to say in certain situations you need to act first to keep others safe. Or that you remove the child from the classroom etc. But that as part of that you work to address the driver of the behaviour. Work to derive the experience that's driven the behaviour and the feelings surrounding that experience. That you work with the pupil to teach them a better way.
Punishment for having feelings you can't manage does not succeed in many cases to a resolution or a solution. It only succeeds in giving the child another negative experience and driving more negative feeling which drives more negative behaviour.
I don't for one moment think when you have a class of 30-35 students to teach teachers have the time to address this with the child there and then. Or it's productive to the learning of everyone for them to devote that time.
But.... "X, I can see you are angry/cross/ not ready to learn. We can talk after lesson. Right now I need you to decide if you are ready to learn and can remain in the lesson or you need to work outside/go to pastoral/ have 5 minutes outside and return".
It's about building up that respect. Building that that they have a voice that will be heard.
There is nothing wrong with a discussion about "I understand you were anxious about X so reacted this way. Let's work together to find a solution to the problem (Eg hand homework in following day by 9am.). Let's work together to find a way to support your organisation so it doesn't happen again. As you know school rules are X. Therefore you need to sit a 30 minute detention for .....".
It's not about not giving consequence, it's about a holistic approach the the child and their needs.
Recently a conversation like this led to a serious safeguarding concern when a disclosure was made.
Had the teacher just punished continuously for the lack of homework the child was likely to have continuously clam up and behaviour may have escalated - and no one would have known what went on behind the closed doors of their home.