"Finally some coding!"
You have learned 'variable' means the same thing as a 'block of memory', and you now understand that you need the computer to create
a 'block of memory' for each 'variable' with its Label and Size/Type. We will now stick with the programmer's term of 'variable'.
variable = block of memory
You also have learned that there are two most used variables.
And finally, you have learned that the computer wants requests for variables to take the syntax of:
Putting all three of items together, you need to do the following to create a variable:
- define the Size/Type and Label
We will start by asking the computer for a Number variable to hold a person's age.
(remember: with numbers, a whole number is called an Integer. Since Age is usually shown as a whole number, you would want an Integer variable)
Oh my gosh, I finally get to provide you with a line of code! *yippeee*
(yes, this is my age at the time of typing this page)
Now that you have the first line of code, the following questions will be answered below:
- what does each part of that line mean?
- how do I type that line into the computer?
What does each part of that line mean?
- var: asking for a new variable
- Age: giving the variable a Label of 'Age'
- =: assigning content to the variable
- 44: the content being assigned is '44'
- ; (semicolon): ending a command line
How do I type that line into the computer?
All programming languages are entered (typed) into a program that handles the work (tasks) being asked by the programmer.
Since you are viewing this lesson, you already have the skills to 'type'. There is no difference in how a 'programmer' enters code, as there is when you
type the address for a Website (URL), type an email, or type up an essay for class.
(URL: Uniform Resource Locator, i.e. Website Internet Address)
The difference between an URL, email, essay and a program is how the computer uses it. If you type an URL into an Internet Browser (like Internet Explorer, Firefox, Safari, Chrome, etc..), the Internet Browser program will take what you typed and pull up a website.
However, if you type the URL into an email or essay, the Email program or Word Processor just displays the URL to you. You are not taken anywhere. Even though the URL text is the same, it depends on what program you use on the computer to enter the URL.
Time for YOU to type this line. Please enter the code:
into the box below.
Now, click on this button to see if you code worked. Since this will cause your Browser to parse the code you enter.
Once you have verified your code with the 'Check My Code' button, go back into the box and change the '44' to another number, then re-click the 'Check My Code' and see how the number changes.
Things to notice about the code you just created:
- programming languages are case-sensitive. This means 'Age' is not the same as 'age'.
- when changing the '44' to another number, did you remember to end the line with a semicolor ';'?
Congratulations! Your now a programmer!