Transitioning from Scratch to Python: A Practical Approach for Learning Textual Programming

How the Session Works
Outline
Practical on arrival
Talk 1
Reflect on practical
Clarify concepts
Practical exercises
at your own pace
Talk 2:
Further concepts
Overall reflection
Continue practical
exercises at home
Getting Started
Log-on
Find portable Python on L:\
drive and start IDLE
Go to 
Find resources on
Exercise sheet (and notes) –
START NOW
Example programs
Slides
teachinglondoncomputing.orghttps://scratch.mit.edu/
undefined
KS3 and Beyond
Transition from Scratch to
Python using Turtle Graphics
T
eaching
  
L
ondon 
 
C
omputing
William Marsh
School of Electronic Engineering and Computer Science
Queen Mary University of London
Outline
A first turtle program in two languages
Discussion: barriers to textual programming
Learning Programming Progressively
The turtle language
Translating between Scratch and Python
Practical examples
Summary
First Program
from turtle import * 
 
# Added code starts here
pencolor('blue')
pensize(10)
 
forward(100)
right(90)
forward(100)
right(90)
forward(100)
right(90)
forward(100)
right(90)
# Added code ends here 
done()
Discussion
What are the challenges of learning textual
programming?
Challenges of Text Programming
Accuracy – easy to make mistakes
Blank sheet problem – lack of starting point
Motivation – not visual
Solving a problem: decomposition
Understanding programming concepts
Sequence, choice, repetition, state (variables)
Debugging
Progress in Learning Programming
KS1 onwards
Computers accept commands: 
algorithm
… turtle often used
Decomposition
: sequences, choice and repetition
Challenges
Learning Scratch versus learning programming
Core concepts
Problem solving and debugging
Programming concepts
Core Programming Concepts
Sequence: one instruction follows another
State: variables hold values and can change
Choice: alternative instructions
Repetition: repeating instructions
Input and output
Values (expressions) versus statements
Abstraction: procedures / functions
Turtle Language – I
Role of turtle in Scratch and Python
Turtle is a little language inside a more general
language
Essential commands
Forward
Left
Right
Pen up
Pen down
General language concepts
Sequence
Repetition (bounded)
Function abstraction
Turtle Language – II
Use of co-ordinates and headings
Get and set co-ordinates
Get and set heading
Also
Distance
Towards
General language concepts
Variables
Choice
Translating Scratch & Python
Same core concepts
Overlapping problems that can be easily solved
num = 0
sum = 0
while x <= 10:
    x = x + 1
    sum = sum + num
print('Sum … is', sum)
Comparing Shapes and Text
No punctuation or
spelling errors
Direct representation of
inside loop
Indentation (Python)
Brackets (C, Java, …)
Control Statements – Close
for x in range(1, 10):
    print(“Hello”)
x = 0
while x != 100:
    forward(1)
if 
mouseDown()
:
    forward(10)
else:
    right(15)
Variables – Set and Change
Later in scratch
Variables:
Sprite
Global
Steps = 0
Steps = Steps + 1
Value of the variables
Python uses
name for both
left and right
hand side of
assignment
Programming Concepts
Introduce Assignment
Exploit different syntax to emphasise that
assignment is not equality
Python
Means the same as:
Total = Total + ItemCost * Number
undefined
Practical Problems
 
Equivalence
Two programs can have same behaviour
Different forms of ‘if’ or ‘loop’
Logical equivalence
Repetition versus loops
Redundant code
Code that makes no difference
Easy to include this in Scratch
Problem 1: If & Logic
Two variables: 'name and 'age'
Which versions are the same?
Problem 2: Counting to 5
Which are the same?
Summary
Ideas for transferring from visual to textual
programming
Core programming concepts: make the
correspondence explicit
Problem solving, abstraction and decomposition:
build on existing ideas
Slide Note
Embed
Share

Explore the transition from visual programming in Scratch to textual programming in Python using Turtle Graphics. Engage in practical exercises, clarify key concepts, and reflect on the challenges and progress in learning core programming concepts. Utilize resources from TeachingLondon Computing to enhance your understanding and practice. Start your programming journey now!

  • Scratch
  • Python
  • Textual Programming
  • Turtle Graphics
  • TeachingLondon Computing

Uploaded on Sep 28, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts Overall reflection Continue practical exercises at home Getting Started Log-on Find portable Python on L:\ drive and start IDLE Go to https://scratch.mit.edu/ Find resources on teachinglondoncomputing.org Exercise sheet (and notes) START NOW Example programs Slides

  2. TeachingLondon Computing KS3 and Beyond Transition from Scratch to Python using Turtle Graphics William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London

  3. Outline A first turtle program in two languages Discussion: barriers to textual programming Learning Programming Progressively The turtle language Translating between Scratch and Python Practical examples Summary

  4. First Program from turtle import * # Added code starts here pencolor('blue') pensize(10) forward(100) right(90) forward(100) right(90) forward(100) right(90) forward(100) right(90) # Added code ends here done()

  5. Discussion What are the challenges of learning textual programming?

  6. Challenges of Text Programming Accuracy easy to make mistakes Blank sheet problem lack of starting point Motivation not visual Solving a problem: decomposition Understanding programming concepts Sequence, choice, repetition, state (variables) Debugging

  7. Progress in Learning Programming KS1 onwards Computers accept commands: algorithm turtle often used Decomposition: sequences, choice and repetition Challenges Learning Scratch versus learning programming Core concepts Problem solving and debugging Programming concepts

  8. Core Programming Concepts Sequence: one instruction follows another State: variables hold values and can change Choice: alternative instructions Repetition: repeating instructions Input and output Values (expressions) versus statements Abstraction: procedures / functions

  9. Turtle Language I Role of turtle in Scratch and Python Turtle is a little language inside a more general language Essential commands Forward Left Right Pen up Pen down General language concepts Sequence Repetition (bounded) Function abstraction

  10. Turtle Language II Use of co-ordinates and headings Get and set co-ordinates Get and set heading Also Distance Towards General language concepts Variables Choice

  11. Translating Scratch & Python Same core concepts Overlapping problems that can be easily solved

  12. Comparing Shapes and Text No punctuation or spelling errors Direct representation of inside loop Indentation (Python) Brackets (C, Java, ) num = 0 sum = 0 while x <= 10: x = x + 1 sum = sum + num print('Sum is', sum)

  13. Control Statements Close for x in range(1, 10): print( Hello ) x = 0 while x != 100: forward(1) if mouseDown(): forward(10) else: right(15)

  14. Variables Set and Change Later in scratch Variables: Sprite Global Value of the variables Python uses name for both left and right hand side of assignment Steps = 0 Steps = Steps + 1

  15. Programming Concepts Concept Comparison Arithmetic operators Logical operators Selection Loops Variables and types Very similar Very similar Very similar Scratch has more forms Scratch does not distinguish strings from numbers Clearer in Scratch Scratch equivalents for input / print No direct equivalent: decomposition Similar No direct equivalent Assignment Input and output Broadcast Functions Sprites

  16. Introduce Assignment Exploit different syntax to emphasise that assignment is not equality Python Total = Total + ItemCost * Number Means the same as:

  17. Practical Problems

  18. Equivalence Two programs can have same behaviour Different forms of if or loop Logical equivalence Repetition versus loops Redundant code Code that makes no difference Easy to include this in Scratch

  19. Problem 1: If & Logic Two variables: 'name and 'age' Which versions are the same?

  20. Problem 2: Counting to 5 Which are the same?

  21. Summary Ideas for transferring from visual to textual programming Core programming concepts: make the correspondence explicit Problem solving, abstraction and decomposition: build on existing ideas

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#