| In this lesson, students will learn how to print text to the console and use comments to add notes to a program. |
Students will be able to:
|
|
In this lesson, you will learn how to print text to the Console in RoboBlocky. This video walks through Interactive Tutorial #12, where you will use the "print text" block to display text in the Console. You will also learn about using the backslash n (\n) to print text on new lines and how to clear the console for new outputs.
We can display text using a "print text" code block, found in the Text menu:
As another option, the "print with newline" does the same thing as the "print" block with the \n character described above:
2. The Console The results of print commands are displayed in the "Console", which is a pane that automatically opens up below the Workspace when something is printed. The Console pane may be toggled open and closed using the Console button at the top right of the Workspace, next to the Launch button.
A comment is a note that we insert in a program to provide information on what the program, or a section of the program, is doing. They are intended to be read by you and others, but they do not affect how the program runs. The computer ignores them. We use the comment block to create and insert a comment in the code (found in the Text menu):
Click on the text in the block that says "comment" and enter your own text. When the code is run, RoboBlocky will ignore any comment blocks. That is, the text you enter into the comment block only appears in the Workspace, not when the program is run. Example 1 shows how we can use comments to make it more clear what a section of code is doing.
|
|
|
The example uses a variety of "print text" blocks to show how printing text and the "\n" newline character work. Comments are used to provide information on what the code is doing. |
| Grid Size: S M L | Simple View: | MinView: |
| Coord: x-axis y-axis | Grid Lines: x-axis y-axis | |||
| Grid: | 12x12 inches | 24x24 inches | 36x36 inches | |
| 72x72 inches | 96x96 inches | 192x192 inches | ||
| 1x1 inches | 2x2 inches | Fraction: | ||
| xy-Range: | ||||
|
|
||||
|
|
||||
| Quad: | 1 Quadrant | 4 Quadrants | 1&4 Quadrants | |
| Units: | US Customary | Metric |
Ruler:
|
|
| Labels: |
|
|
|
Font
px
|
||
| Tics Lines: |
Width
px
|
|
| Hash Lines: |
Width
px
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
(
,
in
) in
|
|
degrees
|
|
|
|||||||||||
|
|||||||||||
