100% found this document useful (1 vote)
106 views

Scratch Computing Backup

This document compares the programming languages Scratch and Python and discusses using them both for GCSE programming. It outlines that while Scratch is simpler, the same core programming concepts can be taught. It also provides examples of how the same problems can be expressed in both languages to demonstrate their conceptual links and ease the transition from Scratch to Python.

Uploaded by

Abhishek Gambhir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
106 views

Scratch Computing Backup

This document compares the programming languages Scratch and Python and discusses using them both for GCSE programming. It outlines that while Scratch is simpler, the same core programming concepts can be taught. It also provides examples of how the same problems can be expressed in both languages to demonstrate their conceptual links and ease the transition from Scratch to Python.

Uploaded by

Abhishek Gambhir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Programming for GCSE

Topic 17: Comparing


Scratch and Python
http://scratch.mit.edu/

William Marsh
School of Electronic Engineering and Computer Science
Queen Mary University of London
Aims

•  Compare Scratch and Python


•  Show conceptual links
•  Consider transition from Scratch to Python

Scratch has recently introduced Scratch


2.0 which is used online but is not yet
(July 2013) available for offline use.

These slides only cover Scratch 1.4


SYLLABUS AND TEACHING
ISSUES
Scratch is usable as one language in GCSE
OCR GCSE – Programming Language
There are no restrictions on the programming language chosen
providing it has the features indicated within the specification. It
is anticipated that the work for this unit will follow on from the
programming elements in unit A451 and that the same
programming language may, therefore, be appropriate. The
tasks are set so that they can be completed in a wide range of
languages including those frequently used to ‘teach’
programming techniques including all forms of BASIC and C.
There may be a question which states that the work must be
completed within a specific package, if this is the case, that
package will be available for free and legal download, for
example ‘SCRATCH’ from MIT and ‘ALICE’ from Carnegie.
Teaching Issue
•  Scratch is fun, but how much is learnt?
•  Problem solving
•  Logical reasoning
•  Programming concepts

•  How to make the links from Scratch to Python


clear?
SCRATCH & PYTHON
Comparing Shapes and Text

•  Less need for variables


•  No punctuation
•  Direct representation of
scope
•  Indentation (Python)
•  Brackets (C, Java, …)

x = 1
while x <= 10:
print('the number is', x)
x = x + 1
Control Statements – Close
for x in range(1, 10):
print(“Hello”)

x = 0
while x != 100:
move(1)

if mouseDown():
move(10)
else:
turn(15)
Variables – Not So Close
•  Later in scratch
Variables:
•  Sprite
•  Global

Value of the variables

Python uses
name for both
Steps = 0 left and right
hand side of
Steps = Steps + 1 assignment
IDEAS FROM SCRATCH TO
PYTHON
Ideas on Scratch to Python

•  Deeper learning in Scratch


•  Concepts
•  Problem solving
•  Equivalence

•  Between Scratch and Python


•  Comparing language features
•  Translating programs
Deeper Learning
Scratch is good for more than just animation.
Scratch programming (including games) is
problem solving. Most concepts carry over.

•  All of the following apply:

•  Pseudo-code and flowcharts


•  Problem solving challenges
•  Testing and fault finding
Programming Concepts
Concept Comparison
Arithmetic operators Very similar
Logical operators Very similar
Selection Very similar
Loops Scratch has more forms
Variables and types Scratch does not distinguish strings
from numbers
Assignment Easier in Scratch; may not transfer
Input and output Scratch equivalents for input / print
Broadcast No direct equivalent: decomposition
Functions (See Scratch 2.0)
Sprites No direct equivalent
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?
Scratch  Python

•  Introducing Python using Scratch


•  Show Scratch translation of Python construct

•  Programming challenge in both Scratch and


Python
Introduce Python's If – Elif – Else
•  Python if var1 < 14:!
print(var1, "is small")!
elif var2 > 22 :!
print(var2, "is large")!
else:!
print("The sum is", var1 +
var2)!

•  Means the
same as:
Introduce Assignment

•  Exploit different syntax to emphasise that


assignment is not equality
•  Python

Total = Total + ItemCost * Number!

•  Means the same as:


Problems for Scratch & Python
•  Many simple exercises
can be set in Scratch
•  … and transliterated into
Python

var1 = int(input("First value? "))!


var2 = int(input("Second value? "))!
if var1 < var2:!
print(var2, "is the larger")!
else:!
print(var1, "is the larger")!
SUMMARY
Summary

•  Scratch may be simple but all programming


concepts present
•  Teach Scratch or Python with same learning
outcomes
•  Basic programming concepts
•  Specification and design
•  Decomposition
•  Testing
•  Emphasise how ideas transfer

You might also like