Learn to Write Computer Programs
To begin this computer programming course, run the given program.
To run the program, click on the 'Run' button.
Afterwards, click on the 'Next' button to proceed.
To run the program, click on the 'Run' button.
The
println (PRINTLN) statement outputs text on the screen
(println is short for print line).
Important:
All names are case-sensitive (purple
is not PuRpLe
nor Purple nor PURPLE).
The editor automatically colors the source code. This feature is known as syntax highlighting.
The disc function draws a disc.
The disc function has the form:
disc(x, y, radius, color)
You can make changes to the given programs, if you like.
Run the program first.
A statement is a basic unit of code.
Important:
Plain statements must be ended by a semicolon (;) symbol.
A text inside quotation marks is called a string.
Strings are printed on the screen exactly as they are stated.
Besides strings, println statements
can also print expressions.
Expressions can use various operators like
+,
-,
*,
/ .
Important:
Parts to be printed out must be separated by a comma (,) symbol.
This program contains an error.
Click on the Check button to get a clue.
The computer will attempt to find out what is wrong,
but it cannot always make a correct guess.
Correct the error and run the program.
Solution...
Many times, 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
(;) symbol at the end.
println "Up above the world so high," ;
Operator * must be used to denote multiplication.
Round brackets (), also called parentheses,
can be used to group expressions.
Square brackets [] or curly brackets
{} (i.e. braces) cannot be used to group expressions.
Run the given program.
You can edit the source code of the program to
print out the result of some other expression.
Use the program to find out the result of expression
The first statement prints the number 12 followed by 7.
That looks like a number 127 if the results are not separated.
A way of separating the results would be to print out some empty space in between.
To make reading more pleasant,
we recommend using the fullscreen mode.
Press the F11 key to enter or exit the fullscreen mode.
It is recommended to always run the given programs as you begin to read the instructions.
Run the given program by clicking on the
Run button, or by pressing the
F8 key. [F8:Run]
This program outputs the expressions together with the results.
At the first glance, it might appear that the given strings contain expressions,
but that is only an illusion. Strings cannot contain expressions.
Strings are printed out as they are stated. Expressions are evaluated before printing.
Here is another error.
Click on the Check button to see the error description.
Correct the error and run the program.
Solution (click):
println 8-(10-(2+7));