Python is a high-level scripting language that combines interpretation, compilation, interactivity and object-oriented.
Note: The version used is Python3.5.2. (Because there is a big gap between the Python2 series and the Python3 series, special reminder)
Addition:
Enter the following code:
>>>1+1 >>>1.0+1
Subtraction:
Enter the following code:
>>>1-2 >>>1.0-2
Multiplication:
Enter the following code:
>>>2*4 >>>2.0*4
Division:
Enter the following code:
>>>2/4 >>>2.0/4 >>>2//4 >>>2.0//4
Note:
Operator: Add - Add two objects
Operator -: Subtraction - Get a negative number or one number minus another number
Operator*: Multiply - Multiply two numbers or return a string that is repeated several times
Operator/: Division - x divided by y
Operator//: Divide by integer - Return the integer part of the quotient (rounded down)
Related recommendations: "Python Tutorial》
The above is the detailed content of How to calculate addition, subtraction, multiplication and division in python. For more information, please follow other related articles on the PHP Chinese website!