Lesson 2 Variable

Variables and Start the Walk Around Project

What are Variables?

A variable is a place in the computers memory where we can store information. This is only for as long as the program is running. You should try and think of different names for your variable that give you a good idea what it is for.

If you are going to keep a count of then goals scored call your variable 'GoalsScored'.

1st Demo


We need variables to hold information in the programs so we can do things. Lets think of the sentence.

'The quick brown fox jumps over the lazy dog.'

This is a sentence that contains all the letters of the alphabet. Lets write a program to display the sentence in the cats speech bubble line by line. We are going to hold the sentence line by line in our 'WhatwasSaid' variable, shown above in Orange. The next block in purple will display the contents of the variable in the cat's speech bubble. We will put some wait blocks in to let you see the information changing in the variable.

I need more help



In the whatwasSaid variable

OK take a look at the picture above. If you have places to put things they are like variables. So lets say we had a card with 'The quick brown fox' written on it. If we put that in our holder it would be there ready for us to use it. By getting another card with the words 'Jumped over' written on it, if we then take out the 'The quick brown fox' and throw it away and replace it with 'jumped over' the variable has forgotten what was there before and has the new word to remember. We call sets for letters strings.

That is one way to explain a string and it is not the only way to explain it. You will realise over this course that understanding what is going on can take a while, if it takes time don't be disheartened this is normal. So look a what is going on again. Look at the picture above, when the text 'The quick brown fox' is entered into the variable, we see the letters go in the numbered boxes. 'T' = 1 'h' = 2 'e'= 3 ect. This is stored in the computers memory ready to be used later. When we want to put 'jumped over the lazy dog' in the exact place the letters are replaced. So we know where the letters are, we call all these numbered boxes a name in the case of this example 'WhatwasSaid'. We can have as many of these boxes as we want in out programs and call them variables.



second demo


There are 2 very basic ways to store information in our variables letters and numbers. We have a word for information we store in a variable and the word is 'Data'. Data stored as letters has a name 'String'. Like a piece of string that you can join another piece of string to it by tying a knot. The second data type we are going to look at is numbers. The name we give it is numeric. There is other data types and we will look at them later.


I need more help



This section is for our members, you can get details of how to become a member on our ready to go page. The members site is here.





Variable Demo



The Walk Around 1 Project


Download the Walkaroud 1 Project

This section is for our members, you can get details of how to become a member on our ready to go page. The members site is here.



Can you make the cool kid walk to the end of the gray path and turn to point up on the path. The code blocks you need are in the sprite script. The variable 'SpeedY' has not been created and will be used later. Can you do that? Then put the code blocks together in a sequence. A lot of the code is new to you so just join it together in a sequence.



This section is for our members, you can get details of how to become a member on our ready to go page. The members site is here.











This section is for our members, you can get details of how to become a member on our ready to go page. The members site is here.