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.