Step 1 – The Scratch code
Once again, I can program this in Scratch.
Take a look at the code. Can you see what it does?
The Scratch code actually takes more lines and is a bit more complex than the Python code will be. There are two reasons for this:
- Scratch needs two lines to get a number from the user and store it away. Python can do this in a single line
- Scratch can't use a WHILE loop. It has to use a REPEAT – UNTIL loop, which is a little bit more complicated
So, let's code this in Python.