Hazel- Scratch Variables

Scratch Variables
1 / 37
volgende
Slide 1: Tekstslide
ComputingUpper Secondary (Key Stage 4)GCSE

In deze les zitten 37 slides, met interactieve quizzen en tekstslides.

Onderdelen in deze les

Scratch Variables

Slide 1 - Tekstslide

My expectations
It's ok to be wrong

Listen when others are speaking

Slide 2 - Tekstslide

Recall
Repeating steps in programming is called iteration. But you know it is as a different term?

Slide 3 - Tekstslide

Recall
Repeating steps in programming is called iteration. But you know it is as a different term?

Loops or Looping

Slide 4 - Tekstslide

Recall
What is the difference between these two blocks?

Slide 5 - Tekstslide

Recall
What is the difference between these two blocks?
One repeats code inside the block 10 times while the other repeats it forever.

Slide 6 - Tekstslide

This Half term

Introduction to scratch
Variables
Selection
Iteration
Lists
Games Design



Slide 7 - Tekstslide

Learning objectives

Know what a variable is

Know how to use variables in Scratch


Slide 8 - Tekstslide

Dictionary definition of a computer variable


"a named memory location in a program that stores a value that can change"


Slide 9 - Tekstslide

What would the new value of score be after running these three blocks of code?

Slide 10 - Tekstslide

What would the new value of score be after running these three blocks of code?

2

Slide 11 - Tekstslide

Orange* blocks of code in Scratch are called Variables.




*we will see later that some variables are set in different colours.

Slide 12 - Tekstslide

Variables are places in a program to store data that you might need later on.




Slide 13 - Tekstslide


They can change as the program runs.



Slide 14 - Tekstslide



You could use this variable, score, to keep track of the score of a game for example.

Slide 15 - Tekstslide



What other variables could you think of that might be useful for a game?

Slide 16 - Tekstslide

What other variables could you think of that might be useful for a game?

Slide 17 - Open vraag



What other variables could you think of that might be useful for a game?


Score
Points
PlayerName
Goals
Lives
Shots
Time
Speed

Slide 18 - Tekstslide

Slide 19 - Tekstslide

PREDICT
Predict what you think will happen.

Slide 20 - Tekstslide

Predict what you think will happen.
Write down your predictions.

Slide 21 - Open vraag

RUN
Click this link or visit 
https://scratch.mit.edu/projects/1084991660/  to run the program

Slide 22 - Tekstslide

Were your predictions correct?
Did anything surprise you?
Did your predictions miss anything out?

Slide 23 - Open vraag

INVESTIGATE
How do the following two blocks of code relate to each other?

Slide 24 - Tekstslide

How do 'ask_name' and 'define ask_name' relate to each other?

Slide 25 - Open vraag

INVESTIGATE
When your program reaches the ask_name block, it calls the subroutine ‘define ask_name’.

‘define ask_name’ is a sub program
or a function.

Slide 26 - Tekstslide

INVESTIGATE
What happens if you remove 'ask 'what is your name' and wait'

Slide 27 - Tekstslide

How do 'ask_name' and 'define ask_name' relate to each other?

Slide 28 - Open vraag

INVESTIGATE
What happens if you remove 'ask 'what is your name' and wait'
Big Ed will now only say “Hello”.
As the question has not been asked, there is no ‘answer’.

The line ‘set name to answer’ will now give name an empty value.

Slide 29 - Tekstslide

INVESTIGATE
Below 'define ask_name'. There are two variables being used

Slide 30 - Tekstslide

Below 'define ask_name'. There are two variables being used. What are their names?

Slide 31 - Open vraag

INVESTIGATE
Below 'define ask_name'. There are two variables being used

Slide 32 - Tekstslide

INVESTIGATE
Why do you think this code only says “Hello” and not “Hello” and the name you entered?

Slide 33 - Tekstslide

Why do you think it only says “Hello” and not “Hello” and the name you entered?

Slide 34 - Open vraag

INVESTIGATE
Why do you think this code only says “Hello” and not “Hello” and the name you entered?

It is because ‘name’ is being linked to ‘answer’ before the question is asked.

You must always set the value of a variable before using it.

Slide 35 - Tekstslide

MODIFY
Modify the code that’s already in the program.

Slide 36 - Tekstslide

Make
Use the code blocks to add a new question to be asked about your favourite sport or hobby.

Slide 37 - Tekstslide