Introduction [2/10]
Learn to Program Now!
Click the “Run” button to see a short animation in action.
Then, click “Next” to begin programming lessons.

To run the program, just click the “Run” button.
The source code of the program has two statements, each on a separate line.
The editor automatically colors the source code, to make it easier to read. This feature is called “syntax highlighting”.
The println (P-R-I-N-T-L-N) statement displays text on the screen. println is short for “print line”.
The disc function draws a disc. Its position, size, and color are specified by values inside the parentheses (also known as round brackets).
Exercise:
Add the following statement to the program: disc( 600,150, 100 , /red );
This complex program creates a short animation. Click the “Run” button to see it.
The program's source code has many statements that work together to produce the animation.
Next, we will make a small change to the program.
Exercise:
Find the second statement in the source code, the one that includes the word ZedLX, and replace that word with a different word of your choice. Then, run the program to see the effect of the change.
* * *
To share the animation with others, just click the Share button above the source code.
Then, enter a title for the program, and leave other fields blank if you like.
Then, click “Create Link” to get a shareable link. You can click the link to see the program in action. Use the sharing buttons on the “Execution Completed” page to share it with others.
Run the program to see it in action.
In programming, “to print out” actually means to display information on the screen.
A text enclosed in quotation marks is called a string. Strings are printed on the screen exactly as they are written.
In addition to strings, a println statement can also print expressions. Expressions can use various operators like +, -, *, and / .
Important Notes:
- Plain statements must end with a semicolon (;)
- To print multiple items, they must be separated by commas (,)
This program contains an error. Finding and fixing errors is a normal part of computer programming.
Click the Check button to get a hint about what might be wrong. The automatic verifier will analyze the code and provide feedback.
Correct the error and run the program.
Hint: The verifier may offer helpful suggestions. In this case, pay close attention to its advice.
Solution...
Sometimes, the actual error is located just before the reported one. This is one such case.
The error is in the third statement: it is missing a semicolon (;) at the end:
println "Up above the world so high," ;
In programming, the * operator
is used for multiplication.
[Run the program]
Round brackets (), also called parentheses, are used to group expressions.
Note that square brackets [] and curly brackets {} (also known as braces) have other uses and cannot be used to group expressions in this way.
Exercise:
Display the result of the expression: 15*3+2*(90+10)
Run the program to see the result.
In the first statement, the numbers 12 and 7 are printed together without separation, appearing as 127.
To separate the numbers, spaces should be added between them.
For a more enjoyable reading experience, we recommend using the fullscreen mode. You can enter fullscreen mode by pressing the F11 key. To exit, simply press the F11 key again.
Exercises:
Add the following statement to the program: println "Jammed together:" , 2, 5, 1+1;
Add the following statement to the program: println "Un-jammed: ", 2," ",5," ",1+1;
The program displays the expressions along with their results.
[Run the program]
It may seem like the strings contain expressions, but that is not the case. Strings cannot contain expressions, they only contain text.
Strings are printed out exactly as they are written. Expressions, on the other hand, are evaluated first, and then their results are printed.
Exercise:
Add the following statement to the program: println "3m × 4m = ", 3*4, "m²";
This program contains an error.
Click the Check button to view the error description.
Correct the error and then run the program.
Hint: The error report may seem complex, but the automatic verifier has actually provided a useful clue.
Solution (click):
println 8 +(10 - (2+7));
Run the program to see the animation.
The source code has multiple features that will remain unexplained.
Let's make some small changes to the source code.
Important Note:
Remember that all names are case-sensitive.
For example, purple
is not the same as PuRpLe,
Purple or PURPLE.
Exercises:
Change the color of the disc to purple.
[Run the program]Replace the number 6 with the number 2 in the source code to slow down the motion.
[Run the program]
<< F2:Prev - - F4:Next >>