Session 11
Switching from Blockly to Python
Objectives
Develop an initial understanding of Python as a text–based language
Understand that Python has precise syntax
Identify characteristics of Python, compare this with Blockly
Use and understand the movement instructions in Python
Use and understand repeat loops in Python (for count in range (n))
Resources | Vocabulary |
---|---|
• Interative Whiteboard (IWB) • Levels 80 to 84 in Rapid Router • Resource sheets 1 and 2 • Code cards (Assets part 3) • Video: 'Python' | • Python • Text-based programming language • Syntax • Indent |
Let's get started
Explain to the class that today they are going to learn about a new programming language called Python.
This will be different from Blockly and you will be asking the class to spot the differences.
Show Level 80 on the IWB. [fig S11.1]
This is a simple challenge. Can we solve it in Blockly?
Choose a pair to do this solution on the IWB.
The class should find that easy and they can now see in the pane below how the Blockly code translates to Python. Draw their attention to the code in Python on the screen. [fig S11.2]
Hand out Resource Sheet 1 between pairs. Ask them to take five minutes to discuss with their partner and write notes on what similarities and differences they see in the two different languages. [fig S11.3]
Recap on concepts of movement and repeat, comparing Blockly with Python. Encourage the students to identify characteristics of Python — text, syntax, indents…
Syntax is the grammatical rules of a language. Spoken English has syntax rules, e.g. it would be incorrect to say “I jumps”.
Experiment to see what happens if you change some of the code in Python.
Paired activity
Ask the students to try Levels 81 and 82, starting off by creating the code in Blockly, and watch it being converted to Python.
Ask them to make a note of the Python commands on their whiteboards.
Mini review
Bring everyone together to discuss what they have learnt.
Recap on the syntax of the my_van.move_forwards() instruction and notice how the my_van., the _ and the () are in the same position for each movement instruction.
The Blockly–Python phrasebook explains this in detail.
Ensure the students understand the terms: ‘underscore’ and ‘brackets’.
Show Level 83 on the IWB. [fig S11.4]
What do you notice on this route? What programming tool can we use to help us? (repeat loop)
Can we write a neat program in Blockly?
Give the students time to discuss and write a possible solution on their whiteboards. Choose a pair to show this on the IWB.
Can you explain how the code in Python works here?
Paired activity
Recreate this solution for Level 83.
Set this task:
Find out what happens if:
you replace the 3 by a 2 or another number in Python.
you replace the word count by any other single word, e.g. number or times
you leave out the : at the end of the line
Those pairs who have completed the task quickly can try Level 84.
Share and review
Discuss what they have found out about the for … in range (n): loop in Python.
What can change and what can stay the same?
Display the relevant Python Code Wall Cards on your display board.
Follow-up unplugged activity
Matching Blockly blocks to Python code with resource sheet 2.
Print, laminate and cut up the Python cards for movement and loops, together with the corresponding Blockly cards. Give each pair/small group a set and ask them to match them up.
Last updated