Rectangle (numerical operations)
- =
-
In this example we create two variables width
and height
containing the numbers 23 and 17 respectively.
Unlike in math, in programming in general where you see a single equal sign =
it means assignment. It means we want the value on the right-hand-side to be in the variable on the left-hand-side.
Others might say make the word/name on the left-hand-side of the =
sign refer to the value that is on the right-hand-side.
In any case this is not a mathematical statement of truth not an equation, but a statement of an action.
On the next line we multiply the values in two already existing variable and assign the result to a third variable called area
.
At the end we use the print
function that we have already seen, to print out the results on the screen.
A simple mathematical operation.
width = 23
height = 17
area = width * height
print(area) # 391