We talk a lot in parliament about whipping. (Not that kind. Get your mind out of the gutter.)

Whipping is what parties do in order to pass and amend laws – or stop them passing, if they are the opposing parties. MPs, in return for receiving their party’s official endorsement and organisational support at an election, are expected to “follow the whip” – that is, the official instruction from their party’s leadership about how to vote on legislation.

Whips also come in three flavours: one-line whips, two-line whips, and three-line whips. A one-line whip means that you don’t have to turn up to vote if you don’t feel like it, but if you do, you must vote with the whip. A two-line whip means that you don’t have to turn up provided you have a good excuse. A three-line whip means turn up or else.

Whips also contain an instruction on how to vote. MPs can be whipped to vote for something, to vote against something, or not to vote at all (we call this abstaining). But they also have a thing called free voting, when MPs can vote however they like.

People often confuse the line of a whip with the instruction on how to vote. But the lines just govern whether you have to attend, not how you have to vote. Under the last Labour government, social rights legislation was often two-line, but with an instruction to vote for. So if your excuse was “I am deeply socially conservative”, you could avoid the vote, but you weren’t allowed to vote against it.

Under Ed Miliband, the vote for equal marriage was a three-line free vote: Labour MPs had to turn up and vote but once they did they could vote however they wanted.

Why do parties do this? Well, it’s partly because not all of the work that MPs do happens in the chamber of the House of Commons, or even in parliament at all. MPs also do work in their constituencies, in their ministerial jobs or for the party in question.

It’s not an effective use of anyone’s time if, instead of doing work in their departments or representing their constituencies, MPs are turning up for votes that are certain to pass or fail. (Most one and two line whips are used for votes where the outcome is known, or if both parties are supporting the legislation.)

It’s also because a party might know that it is certain to win or lose a vote, wants to be able to say that it supports x issue, but one or several of its MPs – perhaps a very important MP, who holds a big job in the party – are opposed, whether through principle or because their constituents are opposed. A one-line whip gives MPs in that position a way out, although they don’t always take it. (In some cases, their constituents are so opposed that only outright opposition to the party line will do.)

Confusingly, each party also has MPs who hold a role called “whip”. Whips have two jobs: the first is to make sure that their fellow MPs follow the whip, and the second is to keep track of the mood among the party’s MPs. It’s embarrassing for the prime minister or the leader of the opposition to call a big vote and then lose it, so the whips not only need to be able to cajole MPs into line but also to know in advance how difficult that job will be.

It’s that intelligence from the whips that the party leaders then decide whether a whip should be one, two, or three line; and if it should be to vote for, against or to abstain.

What about parties where they have just one MP, like Ukip from 2015 to 2017, when Douglas Carswell was the party’s sole representative in the Commons? In that situation, they have to whip themselves. Douglas Carswell whipped himself.

There you go. That’s your reward for getting this far: you now know everything you need to know about whips, and you just read a terrible joke about Douglas Carswell MP.