Most Code Clubs start out with Scratch, but when the time is right, you might want to try out some text-based languages such as Python in your club. In this post, we explain how to introduce the Python language in a fun and engaging way.
When to introduce Python in Code Club
Many programmers use text-based languages like Python because of how efficient and powerful they are. While Scratch is a powerful language that can be used to create quite sophisticated games and programs, a time may come when your learners are asking you how to perform tasks that are overly complicated in a block-based programming language and would be much easier to do in Python. This is a great time to consider introducing this language!
Code Club, meet Python
Here are a few great ways in which you can start introducing Python as a concept to your Code Clubbers:
- Show them real-world examples of the language: if you aren’t familiar with Python yourself yet, don’t worry! Get your Code Clubbers excited about Python by showing them that the language is used to create many of their favourite sites. This list shows that popular websites such as Google, Facebook, and YouTube are use Python code.
- Prove the power of Python: if you are familiar with Python, you could try writing a script that demonstrates how efficient the language is. For example, you could use the language’s built-in mathematical functions to demonstrate how quickly you can solve a maths exercise from a textbook!
- Automate tasks with Python: you can also try slowly incorporating Python into the running of your Code Club sessions. For example, you could write a script based on our Team chooser project that randomly picks one of your learners to do show-and-tell at the end of the session.
How to start writing Python in Code Club
Similarities between Scratch and Python
Once you have introduced your learners to the concept of Python, it’s time to get them writing their own code. This means acquainting them with Python syntax (i.e. the specific rules that determine how the language needs to be written).
A great way to do this is to get the young people to translate a simple project they have made in Scratch into the Python language. The Code Club Scratch project Username generator is perfect for this, and the following image demonstrates how one block from the project can be written in Python:
You can find instructions on how to translate this entire project into Python in the Raspberry Pi Foundation’s free online course Scratch to Python: Moving from Block- to Text-based Programming.
Another useful exercise is to show the children how all the basic Scratch blocks can be written in Python. You could ask different Code Clubbers to choose their favourite Scratch blocks and then work together with them to find out how that block would be represented with Python. In our Scratch to Python online course, you can also find illustrations of many Scratch blocks and their Python equivalents.
Code Club Python projects
Just like with Scratch, our Python projects are designed to gradually introduce children to the syntax and concepts of Python. We currently have two Python modules, starting with the project About me. In this project, learners write a Python program that tells people about themselves using the print() function and ASCII art.
If you’re not familiar with Python, don’t think this means that you can’t introduce the language in your Code Club. Simply try out each project before introducing it to the children and you can develop your Python skills together. You too will start to see how using Python can help you with day-to-day tasks!
Having fun with Python
We know learners love the graphics in Scratch, and moving to Python doesn’t mean you have to say goodbye to nice visual results! Our Turtle race! project in Python module 1 is a great one for demonstrating the fun games and animations you can create with Python:
Using Python in your Code Club means you can also work on long-term projects that show learners the scope and excitement of text-based programming. For example, Astro Pi is an annual coding competition that runs young people’s Python code on the International Space Station, and we always encourage Code Clubs to participate. What’s more exciting than sending your code into space?!
Debugging: community advice
As your Code Clubbers get to grip with this new language, a lot of your session time might be spent on debugging (i.e. fixing errors in code). We asked two Code Club volunteers about their top debugging techniques:
Lorna Gibson, Code Club Regional Coordinator for Scotland:
“When children in my club hit an error in Python, we turn fixing it into a game of ‘spot the difference.’ First I encourage them to compare the worksheet code with their own. If they ask for help again and promise they have already tried to spot the difference, I will go over and have a look. I win a point if I can spot the difference in under a minute. Motivated by competing with me, more often than not they ultimately spot the error anyway. It’s all about scaffolding and building problem-solving skills for the future.”
Darren Townsend, Code Club volunteer:
“I use comparisons of Scratch to Python at the beginning, for example to explain that ‘while True’ is the same as the ‘Forever’ block. I also have some Python cheat sheets which give examples of common Python code. Some of the learners find it easier to debug Python than Scratch, because Python gives you error messages to indicate what went wrong. It’s usually down to spelling errors!”
More guidance on transitioning from Scratch to Python
Feeling ready to take on Python in Code Club? Now is a great time to take the Raspberry Pi Foundation’s free online course Scratch to Python: Moving from block- to text-based programming.
You must be logged in to post a comment.