Arithmetic operators
Before the article in the introduction of variable types, in fact already used a lot of arithmetic characters, such as + 、-、 *,/,//, * *, and so on, in addition, there is a symbol is not mentioned before, is%, used to return the division of the remainder of the operation symbol.
Assuming that the variables x and y,x are 10,y to 3,x%y, the result is 1.
There are precedence in the operators, as in mathematics, so there are some need for precedence in writing, such as: 3 * (4 + 5).
Python supports the addition of different numeric types, which use a number type cast to solve the problem of inconsistent numeric types, that is, it converts one operand to another data type with the same operand. However, the operation of this cast is not arbitrary, there are rules to follow: integer to floating point, non-complex to plural. Can be understood as simple to turn into complex, because the floating-point number can represent the same as an integer value (0 after the decimal point), the imaginary part of the complex is 0 can be used to represent the non-plural.
Now let's look at a small example of 24, mainly to familiarize yourself with the concept of arithmetic operations in Python, and perhaps you have more and better ways to calculate it.
Learn more, just in the code bud Net Http://www.mayacoder.com/lesson/index
Python Beginner Learning Basics Operator--arithmetic operator