GoalCompare block-based Scratch with text-based Python and say what stays the same.
New words
block-based language · a language in which you build a program by dragging blocks togethertext-based language · a language in which you build a program by typing commandssyntax · the exact rules for how the commands of a language must be writtenIDLE · the program in which Python programs are typed, saved and run
Explanation
Scratch is a block-based language, where you drag blocks and snap them together like bricks. Python is a text-based language, where you type every command yourself. Python has strict syntax rules, so one missing bracket or quotation mark can stop a program. Python programs are written and run in a program called IDLE. Both kinds of language use the same ideas: a sequence of steps, input and output. Input is data going into the computer and output is what the computer shows. This is why someone who can use Scratch can learn Python.
Job
Scratch block
Python line
show a message
say [Welcome!]
print("Welcome!")
ask a question
ask [Your name?] and wait
name = input("Your name? ")
do steps in order
blocks stacked under each other
lines typed under each other
Worked examples
Here is a small Scratch program. It shows a message in a speech bubble for two seconds.
Python
1print("Welcome to the zoo!")
Output
Welcome to the zoo!
This Python program does the same job. The word print is a command and the text goes between quotation marks and brackets. Python writes the message on the screen instead of in a bubble.
Idea
Scratch
Python
how you build
drag and drop
type the code
syntax rules
the blocks only fit together the right way
you must write every word and symbol correctly
sequence, input, output
yes
yes
good for
learning the ideas
bigger and more advanced programs
Mia and Leo compare the two languages. Notice that Scratch cannot have a spelling mistake in a block, but Python can.
Class activity
Human interpreter (no computer): your partner writes three lines on paper, for example print("Hello"), print("I am Leo") and print("Goodbye"). You are the computer. Read the lines one at a time and say out loud what appears on the screen. Now the partner makes one spelling mistake on purpose, such as pront. You must say ‘error’ and stop, because Python does not know the word pront. Then play again with picture cards instead: the partner lays out cards that say ‘say Hello’, ‘say Goodbye’ in a row. Which way was easier to get wrong? If you have a computer or tablet, look at a Scratch program and a Python program side by side with an adult.
Practice
1
Give two things that stay the same and two things that change when a program moves from Scratch to Python.
The same: both run the steps in order (sequence), and both can take input and give output. Different: Scratch blocks are dragged, but Python is typed; Python has syntax rules about brackets, quotation marks and spelling, but the blocks in Scratch only fit together the right way.
2
What will the screen show when this program runs? Write the lines in order.
Python
1print("Pens")
2print("Pencils")
3print("Rulers")
Three lines: Pens, then Pencils, then Rulers. The lines are carried out one after the other, from the top, so the output has the lines in that order.
3
Python shows this message and does not run the program. What mistake did the programmer make?
Python
1print("Open at nine)
Output
SyntaxError: unterminated string literal (detected at line 1)
The closing quotation mark is missing at the end of the text. This breaks the syntax rules, so it is a syntax error. The fixed line is print("Open at nine").
4
Write this Scratch program in Python. Python does not wait two seconds, so ignore the timing.