Guess who forgot to post!
Anyhow let’s get to this week’s lesson: Variables!
I know it doesn’t sound fun but this is a very important concept. So what is a variable? Is a tag, or a box that contains information in it.
Let’s say we need to add 2 numbers and show the result. So we ask the user for the first number and STORE it in the first box, we call this first box, let me see what could be an original name? How about BOX1, now my brains are melting.
Let’s call the second box BOX2. In box2 we store the second number but wait we still need a third box, in this one we need to store the result of the adding operation. We call this box resultbox. Do you follow me? And then we tell the computer to add, we do it this way:
RESULTBOX = BOX1 + BOX2
Voila! So now we have the result in the variable called RESULTBOX, was that easy or what?
But why is this important? Well we now see a very simple example with 2 numbers and with a simple operation, but what if we had to do different operations? We’ll save that for later. For now we need to understand that a variable is a box that contains data. You need to know something more, this box is a representation of actual computer MEMORY.
I bet you went to the store one day and the guy talked to you about memory and ram and gigabytes, well next time I’ll explain that too!