PRINT
3*(2+2)
gives the answer 3*4 = 12.
A combination like this is called an expression - in this case, an arithmetic or numeric expression
because the answer is a number. In general, whenever the computer is expecting a number from you, you
can give it an expression instead and it will work out the answer.
You can write numbers with decimal points (use the full stop), & you can also use scientific notation - as
is quite common on pocket calculators. In this, after an ordinary number (with or without a decimal point),
you can write an exponent part consisting of the letter E, then maybe + or -, & then a number without a
decimal point. The E here means '*10
**
' ('times ten to the power of'), so that
(Try printing these out on the ZX81.)
The easiest way of thinking of this is to imagine the exponent part shifting the decimal point along to the
right (for a positive exponent) or to the left (for a negative exponent).
You can also print more than one thing at once, separating them either with commas (,) or semicolons (;
or shifted X). If you use a comma, then the next number will be displayed starting either at the left hand
margin, or in the middle of the line in the 16th column. If you use a semicolon, then the next number will be
displayed immediately following the last one.
Try
PRINT
1;2;3;4;5;6;7;8;9;10
&
PRINT
1,2,3,4,5,6,7,8,9,10
to see the differences. You can mix commas & semicolons within a single
PRINT
statement if you want.
Summary
Statements:
PRINT
, with commas & semicolons
Operations: +,-,*,/,
**
Expressions, scientific notation
Exercises
1. Try
PRINT
2.34E0
PRINT
2.34E1
PRINT
2.34E2
and so on up to
PRINT
2.34E15
You will see that after a while the ZX81 also starts using scientific notation. This is because it never
takes more than 14 spaces to write a number in. Similarly, try
PRINT
2.34E-1
PRINT
2.34E-2
& so on.
2. Try
PRINT
1,,2,,3,,,4,,,,5
2.34E0 = 2.34 * 10**0 = 2.34
2.34E3 = 2.34 * 10**3 = 2340
2.34E-2 = 2.34 * 10**-2 = 0.0234 & so on.