There are three numeric types in Python:
• int: int, or integer, is a whole number, positive or negative, without decimals, of unlimited length.
• float: Float, or “floating point number” is a number, positive or negative, containing one or more decimals
• complex : Complex numbers are written with a “j” as the imaginary part: (e.g. 3+5j).
The interpreter acts as a simple calculator: you 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 (for example, Pascal or C); parentheses () can be used for grouping. For example
Note: Division (/) always returns a float.
To do floor division and get an integer result (discarding any fractional result) you can use the // operator; to calculate the remainder you can use %:
With Python, it is possible to use the ** operator to calculate powers
There is full support for floating point; operators with mixed type operands convert the integer operand to floating point:
variable _ in python:
This means that when you are using Python as a desk calculator, it is somewhat easier to continue calculations, for example:
This variable should be treated as read-only by the user. Don’t explicitly assign a value to it — you would create an independent local variable with the same name masking the built-in variable with its magic behavior.