Download presentation
Presentation is loading. Please wait.
1
Introducing Variables to store information?
Phil Bagge Code-it-co-uk
2
Variables Programming languages, like Scratch, need a way to store information. They use a variable to do this. Variables are like containers, boxes or enverlopes.
3
Variables Computers need a way to find the variable again. So all variables need a label like these labels on our containers. toys furniture keys labels
4
toys Inside a variable We call what is inside a variable the value
furniture keys 2 chairs, 1 table, 1 sofa 1 teddy 3 keys values
5
toys Reading a Variable
When a computer reads a variables label it displays what is inside. toys keys furniture 2 chairs, 1 table, 1 sofa 1 teddy 3 keys
6
Say Hello var friendname how are you?
var is our way of showing that the next word is a variable Say Hello var friendname how are you? If a computer reads this it would display this Hello Mike how are you?
7
Set var friendname to Mike Say Hello var friendname how are you?
var is our way of showing that the next word is a variable Set var friendname to Mike Say Hello var friendname how are you? Mike Set puts the value into the variable friendname If a computer reads this it would display this Hello Mike how are you?
8
If a computer reads this what would it display
If a computer reads this what would it display? Set var friendname to Milo Say Hello var friendname how are you? Milo Set puts the values into the variable friendname
9
If a computer read this what would it say
If a computer read this what would it say? Set var friendname to Milo Say Hello var friendname how are you? Milo friendname Hello Milo how are you?
10
If a computer read this what would it say
If a computer read this what would it say? Set var myage to 10 Say Hey, you are var myage. 10 myage
11
If a computer read this what would it say
If a computer read this what would it say? Set var myage to 10 Say Hey, you are var myage. 10 myage Hey, you are 10.
12
Lisa If a computer read this what would it say? Set var friendname to Lisa Say Hello var friendname how are you? I think var friendname is such a cool name. I wish I was called var friendname. friendname
13
If a computer read the variable more than once what would it say
If a computer read the variable more than once what would it say? Set var friendname to Lisa Say Hello var friendname, how are you? I think var friendname is such a cool name. I wish I was called var friendname. Hello Lisa, how are you? I think Lisa is such a cool name. I wish I was called Lisa. Lisa friendname
14
Variable Fun Create three variables with the following labels and your chosen values Label var bestfriend var favnumber var footballteam Value (you choose)
15
Take turns to read this message to your partner with the variables replaced with your values
Last night I ate var favnumber pies. I hate watching var footballteam on TV as they always lose by var favnumber goals. I am thinking of changing my name to var bestfriend because it sounds much better than my name. (No cheating read them exactly!)
16
Planning to use var name
Write some sentences that use a short name Hello Bob good to see you. You are looking good Bob. I love what you have done with your hair Bob.
17
Planning to use var name
Replace Bob with var name Hello var name good to see you. You are looking good var name. I love what you have done with your hair var name.
18
What is inside the variables?
If the user typed in Mark what would be inside var answer and var name?
19
1 2 1 2
20
Work with your partner to examine this program
Can you work out how the author used a variable to personalise it?
21
Where might you use a name variable in your Maths quiz?
What words, phrases or questions would benefit from having someone's name included as well? Discuss with your partner
22
Recap starter 1, Which block is the input block
2, What is the variable called? 3, Will anyone say the word travel after the method has been chosen? Recap starter travel No they will say the value that is inside the variable not the label that we can see Work in pairs One person holds the card so that only they can see it. The person holding the card asks the first question The other person provides an answer The person holding the card then acts out the rest of the program using the user input inside the variable
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.