 You're here because you want to know how to use variables in Scratch and here I am holding a box What on earth does a box have to do with Scratch variables? Well stick around because in this Scratchery basics tutorial We'll explore using variables and Scratch together and I'll explain what this box has to do with it all coming up Hello world surfing Scratcher here bring you the goodness of learn to go through video tutorials If that sounds like something that you're into then consider hitting that subscribe button if you haven't already Be sure to check out the show notes below by hitting that show more button as I list out a bunch of activities and resources That can help you and your learners along on your learning journeys. All right Let's start to unpack that box of variables first up This tutorial is about variables if you're looking for lists, I've got a card coming up right now in the top corner I'd like you to check out the stage and made boxy boxy is gonna help us understand Variables, I'm hoping that you've got some familiarity with boxes and you know that we use boxes to store things I'm thinking that in some stage in your life You've owned some toys and you may have stored your toys in a box like this Especially if you were moving houses or variables are a lot like boxes and just like boxes They store things and what they store is information and we can think of this information as values So what on earth of values? Well in Scratch, there are two types The first type of value is numbers and you can see here that we've crammed in the number 183 into boxy you can store any number as a variable you store negative numbers you can even Store number sentences so one plus two because it evaluates to three second type of value that you can store as a variable is text You see here that we've crammed the word high into boxy So you can store text you can also store things like your name a sentence and even the join reporter block to combine two different words Now usually if you've got a few boxes you need to name them so things don't get too unwieldy Let's go check out our toy box so that we know that toys are in this box. We can give it a name Let's call it toys You'll see here that we've got the information inside of the box and we've given a name toys So how do you add a variable in Scratch? Well, just about ready to do it head on over to the orange variables category Press it if you haven't then head up to make a variable you prompt it with this dialogue box type in the word toys and Leave everything as in I've got a card in the top corner that will link you to a video that will explain this in further detail Press okay now cast your eyes over here to all the blocks And you'll see that here is our variable with little check mark next to it called toys You can use this check mark to hide and show the variable on the stage here It tells us what its current value is and if you right click on it It gives you some other options You've got the normal read out you put the large read out You've also got a slider that allows you to change the value of the variable We're just going to go back to the normal read out before we talked about the two types of values that you can store in variables The first was a number you can see here that inside of our box. We've got the number 183 Well, we can go over and set the numerical value of toys to that number If you go across to the blocks you drag out the set toys stack block You don't see toys here and you see my variable You can just click this drop down menu and select your created variable there You can go ahead and type in the number 183 and if you press this block you can see here that the variable toys is set to 183 now that's the exact same thing as what we see here in our image inside the box We've got 183 and the box is named toys The second type of value that we can store in a variable is some text or otherwise known as a string You'll see here that in our box. We've got the letters h and i Spelling high we go over to set toys. We can also set that word to a variable I'm going to click this block and you'll see that toys is now set to the text word high Now you don't always want your variables visible here on the stage so to get rid of it Of course you can uncheck the checkbox But sometimes you want to know what the value is of the variable to do that You can also drag out the reporter variable block and you can click it and it comes out with a little pop out here to Reveal the value of that block. That's just a nice thing to note You can also use scratch code blocks to show and hide variables here I've just dragged out the show variable block and we're going to change my variable to toys and Here I'm going to hide variable my variable toys now if I press show variable toys You'll see that it pops up here on the stage again, but notice that over here in our blocks It isn't checked. So that's just something to note if I click hide variable toys. It now goes away I'm going to leave that variable toys up on the screen the last block I want to talk about now is the change my variable block. I'm just going to go change toys here We've currently got toys set to a text value high Which what happens when I press this block it transforms it into a numerical value number one Which what happens when I press it and at the time it increments it by one It changes the value by one if I were to change it by two and press this block It would now be equal to four what I've done to better illustrate This block in action is create a little game where I drop some apples here on the screen with a mouse click What we can do is count the number of apples that we drop inside our box each time I drop an apple and it falls Inside the box. I want this to change by one and every time we miss I don't actually want it to increment at all. So let's go and code that the first thing I want us to do is update the name of our variable to better reflect what it actually does it no longer refers to toys It's actually referring to the number of apples we drop inside of the box So let's rename it to apple count cool the name on the box on the graphic exchange But that doesn't mean anything. We've got to head over to the blocks right click on toys and Rename it. We're going to rename it to apple counts now You can create some capital letters here if you want in programming They usually use this camel case. Sometimes there is an underscore in here, but you can name it however you want Let's just go apple count with a space. All right on a green flag press We want to reset our apple count to zero. So let's get a when the green flag is click block Let's set apple count to zero don't press the green flag and it is now set to zero now We're dropping some apples in and this isn't updating. So I've gone ahead and coded some of this into our apple already Let's jump into our apple now the part that we're interested is in here if we are touching the front boxy So the front boxy is just here. We want to change the value of our apples Now, we know that there is a very handy code block that we can use inside of our variables category Let's change our apple count by one and to press the green flag I'm gonna drop an apple to the side of the apple box and we drop an apple inside the box now And we know that we've got one inside of there. I keep dropping apples You'll see our apple count here is updating which is just unreal So when you think of variables think of boxes with names on them and things that you put inside of boxes It's time for scratch a question. We talked about two types of variables numbers and strings But there are heaps more out there I want to know what are some of the other types of variables that we can use in computer programming Drop a comment below to tell me what you know Hey, thanks for checking out this scratch tutorial on variables like subscribe ring that bell if you're new around here And have a scale some my other content which is on the screen right now If you want to show your support for surfing scratcher then head on over to my patreon page link below in the description We can join a membership tier and that also gives you access to some exclusive content. Hey, it's nighttime here I had a surf already today. I'm just gonna say until then I'll catch you in the next one