Maple - Scratch Variables

Scratch Variables
1 / 41
suivant
Slide 1: Diapositive
ComputingUpper Secondary (Key Stage 4)GCSE

Cette leçon contient 41 diapositives, avec quiz interactifs et diapositives de texte.

Éléments de cette leçon

Scratch Variables

Slide 1 - Diapositive

My expectations
It's ok to be wrong

Listen when others are speaking

Slide 2 - Diapositive

Recall
Repeating steps in programming is technically called iteration. 

But you know it is as a different term?


Slide 3 - Diapositive





Loops or looping




Reuse
Iteration means?

Slide 4 - Diapositive





Loops or looping




Reuse
Iteration means?

Slide 5 - Diapositive

Recall
What is the difference between these two blocks?

Slide 6 - Diapositive

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

Slide 7 - Diapositive

This Half term

Introduction to scratch
Variables
Selection
Iteration
Lists
Games Design



Slide 8 - Diapositive

Learning objectives

Know what a variable is

Know how to use variables in Scratch


Slide 9 - Diapositive

What the Dictionary says:


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


Slide 10 - Diapositive

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

Slide 11 - Diapositive

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

2

Slide 12 - Diapositive

Orange* blocks of code in Scratch are called Variables.




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

Slide 13 - Diapositive

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




Slide 14 - Diapositive

Remember

Variables can change as the program runs.



Slide 15 - Diapositive



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

Slide 16 - Diapositive



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

Slide 17 - Diapositive

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

Slide 18 - Question ouverte



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


Score
Points
PlayerName
Goals
Lives
Shots
Time
Speed

Slide 19 - Diapositive

Slide 20 - Diapositive

PREDICT
Using your Whiteboards Predict what you think will happen.

Slide 21 - Diapositive

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

Slide 22 - Question ouverte

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

Slide 23 - Diapositive

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

Slide 24 - Question ouverte

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

Slide 25 - Diapositive

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

Slide 26 - Diapositive

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

Slide 27 - Question ouverte

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

'ask_name’ is a sub program
or a function.

Slide 28 - Diapositive

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

Slide 29 - Diapositive

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

Slide 30 - Question ouverte

INVESTIGATE
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 31 - Diapositive

INVESTIGATE
Below 'define ask_name'. There are two variables being used. Answer on your whiteboards

Slide 32 - Diapositive

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

Slide 33 - Question ouverte

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

Slide 34 - Diapositive

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

Slide 35 - Diapositive

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

Slide 36 - Question ouverte

INVESTIGATE
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 37 - Diapositive

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

Slide 38 - Diapositive

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

Slide 39 - Diapositive

Question: What is a variable in Scratch?

A) A way to store a value that can change, like a score or a name. 

B) A way to hold a value that doesn’t change during the game. 

C) A way to keep track of how many times something happens in 

D) A tool to change the appearance of a sprite on the screen. 

Slide 40 - Diapositive

Question: What is a variable in Scratch?

A) A way to store a value that can change, like a score or a name. 

B) A way to hold a value that doesn’t change during the game. 

C) A way to keep track of how many times something happens in the game

D) A tool to change the appearance of a sprite on the screen. 

Slide 41 - Diapositive