Image copyright PA

A system of proportional representation called the Single Transferable Vote - or STV - is used for Scottish council elections.

In each part of Scotland, there are three or four councillors - the number depends on the size of the ward and its population.

This is decided by the national Boundaries Commission and not the local authority.

Voting is straightforward - counting the votes is complex.

A voter numbers their candidates in order of preference and can vote for as many or as few as they wish - they should mark a 1 against their favourite, a 2 against their second favourite and so on.

Anyone who only wants to vote for one candidate is advised to place a figure 1 by their name - not a cross.

The number of first preference votes for each party will be watched with interest as it may offer clues to the way people will vote in the UK general election in June.

Voting is simple - but actually translating votes into councillors involves some complex mathematical calculations.

Image copyright Getty Images Image caption Councillors are not picked using a simple tally of votes - it's a much more complicated system

First of all a "magic number" - a quota - is calculated. Anyone who gets this number of first preference votes is elected.

The quota is worked out using a simple enough formula. The number of valid votes cast is divided by the number of seats to be filled plus one. Then one is added to this total.

For example if 5,000 votes were cast in a ward with 4 councillors, any candidate who received 1,251 or more first preference votes would be automatically elected.

But the calculations are usually more complex than that.

It will often be the case that no candidate will secure the "magic number" of first preference votes and usually the other choices play a crucial role determining just who is elected.

It is also possible, though quite unusual, for the candidate who got the most first preference votes to not win a seat - they might not have got the "magic number" of first votes plus enough of the other preference votes to push them to the total.

Here's a rough guide to how candidates are elected:

If nobody reaches the magic number...

The candidate with the fewest first preference votes is eliminated. That candidate's second preference votes are then looked at and are added to the totals of the other candidates. Any who reach the magic number are then elected. If seats still need to be filled, the person with the second fewest first preference votes is eliminated and their second votes are transferred to the remaining candidates Any who reach the magic number are then elected. If seats still need to be filled, the person with the third fewest first preference votes is eliminated and their second votes redistributed and so on, and so on.

The number of times the exercise needs to be repeated may depend on the number of candidates standing.

For instance, if six people are standing for four seats it may be more straightforward than in an example where 14 are standing for three.

If a candidate reaches the magic number of first preference votes...

That candidate is elected. That candidate's second preference votes are allocated to the other candidates. But a formula is used - a so-called transfer value - which depends on how many votes that candidate got over and above the magic number. So for instance, 100 second preference votes may only add 40 to that candidate's total.

The whole process is extremely complex and returning officers declare the result in detail - explaining who was eliminated at each stage.

The system is designed to try to ensure the most popular candidates are elected. Tactical voting to try to ensure someone you do not want is not elected is very hard.

The best advice is to only vote for the candidates you actually want.

Candidate guessing game

One challenge for the most popular parties is to try to decide how many candidates to put up in each ward.

A popular party may manage to get two, three or even four candidates elected in a four-member ward.

If they put up too few candidates, they could end up being under-represented.

But if they put up too many, their vote could be spread too thin and they could also end up under-represented.

If a party puts up more than one candidate, they may try to manage their vote to maximise the number of candidates who are elected.

'Vote until you boke'

They would urge their supporters in one part of the ward to give their first vote to a particular candidate, their second to another named candidate and so on.

But they would offer different advice to supporters in another part of the ward.

Voters are, of course, free to decide whether to listen to this advice.

However, there is also an argument - which some in Northern Ireland articulate using the somewhat poetic phrase "vote until you boke" - that it is better to number all the candidates on the paper in order of preference, including those a voter actively does not want to see elected, or even detests.

This may have denied the DUP an overall majority in the recent Stormont elections.

But past experience in Scottish local elections suggests that, for example, an eight or ninth preference vote would only come into play in particular mathematical circumstances.