3 years ago
sailingperson
in English · 7,022 Views
likes 9clips 1comments 1
Lesson 1: Numbers and Letters, Words and Things
One of the key aspects of programming is data. Information. Things you want to store or keep track of or use or modify, the list goes on. In programming, information is broken into several different categories: Numbers Strings (Words) Characters (Letters) Boolean (a representation of True/False) Each of these categories has specifics that go along with it: How information is handled, how you can access it, how you can change it, but all of them have a few things in common, the foremost of which is assignment. . Assignment is when you assign (get it? they were clever when they invented coding) information, let's say a number, to something called a variable, which holds the information (and can take various types of information, see? various ~ variable, clever..). So here is what we have: Information (let's use word 'vingle') and a variable (let's call it 'ourWord') to put it in. How do we do this? Easy. ourWord = vingle The equals sign here is an 'assignment operator', and does not mean that two things are equal to eachother, rather it states that ourWord is now equal to vingle. ourWord now represents the word 'vingle'. We can do this with other things as well. ourNumber = 2014 ourCharacter = d ourBoolean = True Each of these sets the variable on the left to hold the information on the right. Let's step back for a moment and look at why this is important. If we used these variables in a larger piece of code, we could just replace them with their actual values right? Wrong. Doing this is a REALLY bad habit. Say you mistype 2014 as 2015, and now your program doesn't work because of it. It is much easier and more elegant to use a variable, you can set it at the beginning of your code, and no matter what you do, things will be consistent whether you type 2014 or 2015. The main takeaways from this are that: data comes in various types (numbers, words, characters and booleans), and that we can use things called variables to store this data. We store this data by means of the assignment operator (=). Great job so far! Next time we will be talking about changing a variables information after it has been assigned.
sailingperson clipped in 1 collections
1 comment
Thank you for this nice guide, @sailingperson! It was a really simple way to learn things I thought were a bit beyond me. Can't wait to learn more!