Numbers
The interpreter acts as a simple
calculator.
We can type an expression at it
and it will write the value. Expression syntax is straightforward.
The operators +,
-, * and /
work just like in most other languages (like Pascal or C).
Parentheses (())
can be used for grouping.
Division (/)
always returns a float.
It is possible to use the ** operator to calculate powers.
The equal sign (=)
is used to assign a value to a variable.
If a variable is not “defined” (assigned a value), trying to use it will give you an error.
There is full support for floating point; operators with mixed type operands convert the integer operand to floating point.
In interactive mode, the last printed expression is assigned
to the variable _. This means that when you are using
Python as a desk calculator, it is somewhat easier to continue calculations.
No comments:
Post a Comment