The Same Program in Text
๐ฏ Take a project you have already built and write it again in Python โ and see that you already know how to program.
๐ก The idea behind it
Blocks were never the point. Everything you learnt โ loops, conditions, variables, functions, lists โ is exactly what text languages have, with different punctuation.
๐งฑ Blocks you will need
define (My Blocks) โ defrepeat โ forforever โ while Trueif/else โ if/elsevariable โ variablelist โ list
๐จ Build it
- Take the quiz project from Std 6โ8. Write its questions and answers as two Python lists.
- 'repeat (length of questions)' becomes 'for i in range(len(questions)):'.
- 'ask and wait' plus 'answer' becomes 'reply = input(questions[i])'.
- 'if answer = item i of answers' becomes 'if reply == answers[i]:'. Note the double equals โ the one thing blocks protected you from.
- Run it. The same program, the same logic, twenty lines of text. You did not learn a toy; you learnt programming.
๐ Make it harder
- Rewrite the high-score insert in Python and then replace it with sorted().
- Move to Star Blocks in Code Master, or to a Python tutorial โ you are ready for either.
๐ Bugs you will hit
- '=' assigns and '==' compares. This single confusion accounts for most first-week Python errors.
- Indentation is not decoration in Python โ it is the syntax. What a block's C-shape showed you, spaces now show the computer.
โฌ Need Scratch itself?
Free from MIT, in a browser or as an offline app that needs no connection at all.