In this activity, we are going to learn how to assign a value to a variable, which is like a container in the computer's memory. After we put a value in the variable, we will output the contents of the variable to the output window. This requires two lines of code. In the first line, we will create a variable of the the type: text , give it the name phrase and give it a value of "Welcome to the Skynet Robotic Telescope Network." which is done within quotation marks. The format for this command is:
variableType variableName = "variableValue"
In our example, the first line of code you need to enter should look like this:
text phrase = "Welcome to the Skynet Robotic Telescope Network."
On the next line, we will output the variable in the terminal output window like this:
Notice that the variable phrase in the output line is typed exactly like it is on the first line of code (including capitalization) and that there are no quotation marks around it. Now you are ready to select the green Run Program button below the editor on the right (second in the tab order).
Make the computer combine two variables together in the console output. To do this, start by creating two text variables with different names and assigning values to them. Next, add them together in your output statement with the + symbol. For example, make two variables called phrase1 and phrase2 with the values: "My favorite planet is " and "Neptune" so that when you output phrase1 + phrase2, the computer puts: My favorite planet is Neptune in the console.