Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
As soon as we write even the simplest program in any programming language, we have to keep track of pieces of information. If we are building a loan calculator, we need to keep track of the amount of the loan, the number of months, the interest rate. If we are writing a game program, we might need to know the current score, the position of the player on the screen, how many lives do we have left, what image do we use for our player. This is all data and we create variables to hold that data.
No other characters are allowed but you can't actually start with a number. So this variable name for example would not work, but reversing them so the number's at the end, that would work, and we will talk more about naming our variables later on when we talk about style guidelines, but I am just going to use simple names for now. All we are doing when we create a variable is carving out a little area of memory to hold a value. Right now after this line of code runs, this variable exists.
So be careful when you're naming your variables. Now if you are creating multiple variables at the same time, you can of course do them on multiple lines like this but you can actually combine them on to one line, separating the variable names with commas. It's just a shorthand way of doing this. And similar to that if you're actually creating multiple variables and giving them all initial values you can still combine them on to one line. This makes it a little easier to read, a little shorter to write.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101128 Viewers
61 Video lessons · 87889 Viewers
71 Video lessons · 71763 Viewers
56 Video lessons · 103634 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.