teaching variables to familia
I've always been terrible at explaining things, but over the years, I feel like I've gotten a little bit better. And even if that's not true, I want to attempt to teach you guys something that I've always been passionate about. I want to teach you guys how to program. Even if it's just the basics. I want to be able to convey in plain English what it is that makes it so fun and satisfying for me and why I think you can enjoy it too!
One of the best ways to learn something new is by relating it to things you already know. So I want to explain a concept called
variables, which is a classy word in programming that is defined in some random dictionary as:
a symbolic name given to an unknown quantity that permits the name to be used independent of the information it represents
But this doesn't really help us or explain ANYTHING AT ALL. So let's take a step back. Let's figure out how we can relate variables to something we already know. For example, CHORES (our favorite thing in the whole world).
Let's pretend that mom wants to assign a bunch of chores to us. She starts with my name first.
In this case, I am "vacuuming". It sucks, and I don't want to, and Mom hasn't even told me how many times I have to vacuum yet, I just know that JOSH-EQUALS-VACUUMING.
With computers, we have things called
variables which help explain what that thing is. The fact that
josh = "vacuuming" is a totally legit programming statement and the computer will be able to read it. What it tells the computer is that we have a variable named
josh and it is equal to
Another big takeaway is that thing josh is equal to "vacuuming" which is in quotes! This is because the variable can only be equal to certain things. In this case it is set to something that is called a String. No, no, not that kind of string. A String in programming is just another classy word for "word" or "sentence". To just repeat this once more: anything inside quotes are just words or sentences. But it doesn't end there. Variables can be set to Numbers and do math as well! But we'll get there. Let's get back to our chores example.
Mom still hasn't finished her list. She has like 5 more kids that need to help with laundry, dishes, dusting, pull weeds, the whole house.
Here's where you get to help mom finish up her list. In the field below, add your name and everybody else who needs to help out. You already know what your chores are. There's also a value missing. Try and figure out what I mean by value, but in case you get stuck, there is a hint as to what all the chores are in the paragraph above.
And the results of you filling these variables in (and the missing value for the last variable):
Josh = "vacuuming" = "laundry" = "dishes" = "dusting" = ""
Congratulations! You've officially written your own variables (and that darn missing value)! Mom and Dad would be so proud. Notice that you can pretty much assign these chores to anybody. You can even assign them all to Dad! Just kidding. The computer actually wouldn't like that and in fact might give you an error or tell you that he's only going to do the last chore since a variable can only hold one value at a time. But the bigger thing to understand is that you can name the variable anything and it will always equal to the thing that is on the right hand side of it. What we did in our case was assign a chore to each person in our family. And a classy way to say this is we assigned a value to a variable.
In the next post, we'll continue with this concept of variables (things that hold values) and explore what other things they can hold.
← back to all posts