Pupils in Helensburgh were ranked among the world's best young coders during an international contest.

Two classes from Lomond School placed in the final results of the annual Hour of Code scheme, which takes place during Computer Science Education Week each December.

The school's 3F.com computer science class came second overall in the high school category.

And the primary seven class finished in the top 10 in their group.

James McPherson was a member of the 3F team.

The 14-year-old said: "I really enjoyed taking part in this competition and was surprised we did so well, as we were told that schools from all over the world were taking part.

"I'm looking to study engineering at university, so taking part in coding competitions like this is really valuable as well as being a fun experience."

Helensburgh Advertiser: 3F.com senior pupils (L-R) Callum, Ruairi, Logan, Florence, Layla, James, Ben, Matthew, Cian3F.com senior pupils (L-R) Callum, Ruairi, Logan, Florence, Layla, James, Ben, Matthew, Cian (Image: Lomond School)

Lomond School was the only establishment that had two classes ranked in the final results at a contest, with entries from more than 140 countries.

Pupils worked in teams using Blocks and Python code to solve maze-type puzzles.

They could gain up to three gold stars for solutions that were classed as "optimum", explained the school.

Lomond also won a year's supply of licences for pupils to use Codementum online coding resources. They will be used throughout the school during the year.

Principal Teacher Claire Chisholm said: “Though unsurprised, given the talented pupils here at Lomond, I'm utterly thrilled by this achievement from our T2 and S3 pupils.

"STEM activities (Science, Technology, Engineering and Mathematics) are a huge part of Lomond School life and it's wonderful to see our pupils recognised on the global stage like this. They should all be extremely proud of what they’ve achieved."

Calum Gordon, teacher of computing science and organiser of this event, said: "When you see the number of classes, schools and countries that participated from all over the world, this was an amazing achievement for a small school like Lomond School and one that we can be very proud of."