© Tyl Software Foundation 2019-2021
▶ NUMBERS
Number is a positive, zero or negative whole number, in the range
{ -2147483648, +2147483647 }.
Consider this program:
age 22
print age
22
First, we assign the numeric value 22, to the
age
variable. The
print
function is a system function
that handles printing of variables.
Numbers can be added by the '+'
operator:
oneplustwo 1 + 2
print oneplustwo
3
Assigning sum of variables to a new variable:
num1 1
num2 2
sum num1 + num2
In the line
Other options of adding numeric variables and numbers:
sum num1 + num2
, the sum of num1
and num2
variables is
calculated, and then is assigned to sum
variable, which will be of numeric
type.
Other options of adding numeric variables and numbers:
num1 1
num2 2
sum1 num1 + 2
sum2 num1 + num2
print sum1
print sum2
print 1 + 2
print num1 + num2
3
3
3
3
3
3
3
Consider this shopping list program:
tshirtsnum 2
tshirtprice 32
tshirtsprice tshirtsnum * tshirtprice
print 'The price of ' + tshirtsnum + ' T-shirts is: ' + tshirtsprice
bluejeansnum 2
blackjeansnum 1
totaljeansnum bluejeansnum + blackjeansnum
jeansprice 42
totaljeansprice totaljeansnum * jeansprice
print 'The price of ' + totaljeansnum + ' jeans is: ' + totaljeansprice
sumtotal tshirtsprice + totaljeansprice
print '-----------------------------------'
print 'SUM TOTAL: ' + sumtotal
The price of 2 T-shirts is: 64
The price of 3 jeans is: 126
-----------------------------------
SUM TOTAL: 190
The price of 3 jeans is: 126
-----------------------------------
SUM TOTAL: 190