Exploring how syntax works in Python by spotting, fixing and understanding errors.

To follow Python’s syntax rules so the computer understands my instructions.
I can identify what Python needs to run correctly.
I can spot and fix simple typing or spacing errors.
I can explain why following Python’s rules matters.
Watch
Watch
Explain that the children will create a mind map to help them remember what they learnt about the similarities and differences between block coding and Python in the previous lesson. Hand out whiteboards and pens (one each) and display the Presentation: Mind map. Read the slide aloud and allow time for the children to complete the activity.
Explain that the children will create a mind map to help them remember what they learnt about the similarities and differences between block coding and Python in the previous lesson. Hand out whiteboards and pens (one each) and display the Presentation: Mind map. Read the slide aloud and allow time for the children to complete the activity.
Take feedback, highlighting key ideas and addressing any misconceptions. They may recall:
Both block code and Python give instructions for the computer to follow.
MakeCode and Python can control the micro:bit to show text or patterns.
Block code uses visual blocks, while Python uses typed commands.
Loops in MakeCode (repeat) match 'for i in range()' in Python.
Both use pauses or timing to control when things happen.
Python needs correct spelling, symbols and indentation to work properly.
Take the children into a large space such as the hall or the playground. Explain that they will take part in an activity where they are robots and the teacher is the programmer. The programmer will give commands and the children must follow them exactly as spoken.
Read the three clear instruction sequences from the Resource: Programmer commands. Give slow, clear commands and end each sequence by saying, “End of program,” so the children know when to stop.
Repeat the activity using the three unclear instruction sequences to model broken or vague instructions.
Ask the children:
Take the children into a large space such as the hall or the playground. Explain that they will take part in an activity where they are robots and the teacher is the programmer. The programmer will give commands and the children must follow them exactly as spoken.
Read the three clear instruction sequences from the Resource: Programmer commands. Give slow, clear commands and end each sequence by saying, “End of program,” so the children know when to stop.
Repeat the activity using the three unclear instruction sequences to model broken or vague instructions.
Ask the children:
Take feedback and explain that Python works in the same way as a robot. It needs clear, precise instructions to understand what to do.
Explain that syntax is the name for the set of rules a computer uses to read code.
Display slide 1 of the Presentation: Punctuation matters! Read the sentences aloud.
Discuss how small changes in punctuation can completely change the meaning. Explain that Python syntax works in the same way. Python needs the correct symbols, spacing and structure so the computer can understand the instructions. A missing colon or incorrect indentation is an example of incorrect syntax. When the syntax is wrong, the program stops because the computer cannot guess what was meant.
Play the Pupil video: What is syntax?
Group the class into table teams and hand out a whiteboard and pen to each group. Display slide 1 of the Presentation: Syntax showdown.
Show the two code snippets side by side. Ask the teams to decide which version is correct and explain why. Encourage them to check for small details such as colons, indentation, spelling and spacing.
Share lessons with your friends and colleagues for free.

Used in 8,390 schools!