So let's talk about variables. So a variable is a placeholder for storing
a value. Reclaim and store it to avoid
re-computation, or to give a value a name to help understand what it represents.
In Python valid variable names consist of combinations of letters, numbers and the
underscore character. This character right here.
The name has to start with either a letter or a underscore.
We'll talk about when you wanna use underscore later in the class.
The variable names are case sensitive. Typically, for now you should start with
lowercase, then we'll tell you when you use uppercase conventionally later in the
class. Here's some examples of a, ninja, very
nice variable name. Capital ninja.
Pretty good variable name also but don't use it until later in the class.
Ninja underscore, underscore, underscore, underscore.
Great gamer name, maybe not so great Python name.
Illegal names. A number.
1337. That actually has a meaning, that is
called leet speak. One as in L, three as in E, E, seven as a
T, leet. You can't be a leet, ninja unfortunately,
at least not using numbers. If you want to have a multiple word name,
variable name, it's fine. Just connect all the words using an
underscore, that's python convention. So, for example, a legal name is elite
ninja. If you want that to be even more elite you
could be leet ninja. Or if you want to quantify your ninjaness,
you can say, ninja<u>elite.elite. Unfortunately, you still can't start with</u>
the number, so this is not going to work. How do you actually take that value and
assign it to a variable? Well, you use equals.
This is the same thing you did in, say middle school algebra.
You say, variable equal value. Now notice that if you want to test to see
if two values are equal you use a double equal.
So, single equal is assignment, double equal is equality testing.
Now, probably the most critical thing that you need to do whenever you want to go
through and actually choose variable names is to think about something that's
memorable that will help you understand what the variable represents.
So, for example, if I will go through and I say up here, I say M.
Variable M, what does it represent? Not sure but if I say my underscore name,
I bet you can guess what that's going to be.
It's going to be Joe Warren. So I can ask to print that out.
Print my name, run that. Sure enough it's Joe Warren.
I get another variable. I can say, my age. My age, number is 51.