Words can be printed with the command print. The words need to be placed within quotes. We will use single quotes, although double quotes also work. Here is how to print one word:
print('mathematics'); // single quotes print("mathematics"); // double quotes
Here is how to print a whole sentence, all at once:
print('Mathematics is fun!');
If you use the command print twice or more, all of the output is printed on the same line on the printer. For example, these two lines of code:
print('Hello'); print(' world.')
Would print both words on the same line. So, the output would look like this:
Note that we printed a space before the word 'world'. This provides the necessary space between words when they are all printed on the same line.
You can print values with print. The values will not be rounded when you print this way, however. Do not use quotes when using print with values, as in:
This will print a lot of decimals and look something like:
While if you use printNumber:
The example program shows how the command print outputs on the same line when used repeatedly. Again, note that spaces must be printed so that they appear between the words.
Again, we use the command printNewLine before it is covered in the next tutorial. Hopefully, its operation is easy to understand. It is the way that you get off of a line of printing, since the print and printNumber commands alone will never do that.
The program also demonstrates the command's output when printing values. It is usually better to use printNumber for that, though.
Next tutorial: Printing a new line
Here are some links to related articles at EZ Programing Demos: