it depends what they learnt and understood before...
I would never dump code in front of students as a first thing...
I would teach the basics of algorithms without any programming language, using students standing on floor tiles in the classroom
and one student tells the "runner" to execute actions with simple orders (step, turn 90° left, shake hand, stop) given a student facing a given direction at start. The mission is to complete a path and go and shake hands with a few fellow students and come back to where they were at started.
someone notes the list of commands
step
step
step
step
turn 90° left
step
step
step
shake hand
turn 90° left
step
step
step
step
turn 90° left
turn 90° left
turn 90° left
step
shake hand
turn 90° left
turn 90° left
step
step
step
step
STOP
and then explain you have built your first algorithm
then introduce repetitions repeat step 4 times or tests repeat step until some condition is true
then introduced named functions (a list of actions with a name) ) for example a student would be trained to execute a few orders and when you call that student name, he steps in the place of the runner, execute the "danse" (the orders) and then the runner takes the place of the "function guy".
etc...
That's the basics of algorithmics (and what Logo was doing or apple has been doing with Swift Playgrounds and tons of other companies).
as you expand the possible tools at your disposal (operators, variables, ...) you can make more complex algorithm.
There are infinite variations on this to do that without a computer at all and make it very engaging and fun (competitions).
you can then explain how to represent this with a flow chart as a visual tool and introduce a coding language to represent these orders.
you can group orders that are similar in "statements" and explain you have various types (start with expression statements, compound statements, selection statements, iteration statements, jump statements) and show how do something while(condition) is different than while(condition) do something
only once they have understood the various statements, the language and grammar and what an algorithm is would I go for the type of question you ask — proposing different ways of coding something.
If you build on sand or on notions that the students did not understand, then for sure they will fail miserably and hate the topic. If you make it fun, engaging, playful, rewarding then you build the next generation of engineers or technicians.
my 2cts.