27 February 2023
Moving pupils from Scratch to Python
The main obstacle to learn text-based languages is understanding the specific syntax needed. Pupils at this stage tend to make many syntax errors, and this frustrates them and demotivates them. One thing that we can do as teachers at this stage is to show the parallels and differences between Scratch and Python syntax using an easy-to-use online IDE such as Trinket (https://trinket.io/ ). Let’s look at some examples of parallel programming activities:
- Inputs/Outputs: Show a simple input and output Scratch program and ask pupils to predict what will happen (Oracy opportunity); then show them in Python.
- Variables: Remind them how a variable is created in Scratch before you model it in Python (Pair programming opportunity).
- IF statements: Provide for them a Scratch program that shows different outputs depending on an input, then provide the code in Python and ask them to discuss the differences (Oracy opportunity).
- For loops: Model how to create a loop to output the numbers 1 – 10 in Scratch, then model a simple counter-controlled loop in Python (Debugging opportunity).
- While loops: Demonstrate in Scratch how to add numbers inputted until they input 0, then it outputs the total with a message. Demonstrate the same conditional loop in Python (Pair programming and debugging opportunity).
You can provide the following challenges for pupils to complete in pairs or individually using Python:
- Input/Output/Variable challenge: Show them a Scratch program that adds 2 inputs and outputs the result.
- IF statements: Show them a Scratch program that outputs a grade based on a percentage.
- For loops: Show them a Scratch program that accepts a message and an integer d outputs the message the specified integer inputted.
- While loops: Show them a Scratch program that simulates a log-in screen and keep asking for the password and/or username while it is incorrect.
There is also the possibility if you have micro:bit devices to use the micro:bit editor (https://makecode.microbit.org/60883-50631-39442-27845 ) to further enhance their experiences by using Physical computing. As well as seeing their output of the program on the on-screen emulator, the pupils can also download the .hex file onto a physical micro:bit. There are loads of example programs and support online through The CAS and NCCE resources for free.
Finally, there is EduBlocks to transition smoothly from Scratch-style coding to text-based programming. EduBlocks (https://app.edublocks.org/editor ) is an online Python block editor. Each block has a line of Python code on it, rather than a single word or verbal command. This way, pupils will start to read Python code while using the blocks. After a while, they will be ready to move to atext-based IDE like Idle, Trinket, Thonny, etc.
Do you transition from block to text-based programming in a different way? Please share.