Reference link: Division operator in Python
Arithmetic operator is a kind of operator, generally used to deal with four arithmetic operations.
/ Divide by 10/20 = 0.5
// Round and divide return the integer part of the division (quotient) 9 // 2 outputs the result 4
% Take the remainder Return the remainder of the division 9% 2 = 1
**Power is also called power, power, 2 ** 3 = 8
In addition: In Python, the * operator can also be used for strings, and the calculation result is the result of repeating the string a specified number of times
print("+"*20)
console:+++++++++++++++++++
Consistent with the precedence of operators in mathematics, the same is true when performing mathematical calculations in Python:
Multiplication and division followed by addition and subtraction. Operators of the same level are calculated from left to right. You can use () to adjust the priority of calculation. The following shows that the arithmetic priority is arranged in order from highest to lowest:
the first: **
Second: *, /, %, //
Third: +,-
E.g:
2 + 3 * 5 = 17
(2 + 3) * 5 = 25
2 * 3 + 5 = 11
2 * (3 + 5) = 16
How can there be less joy in programming:
My wife said diligently: "My husband, what time do I get off work, miss you!" Husband: "Talk about business!" Wife: "I saw a package online
The bag, this year's new style, is particularly beautiful, and it is still limited. "Husband: "Talk about the point!" "Wife:" It's just a bit expensive, it costs one thousand and eight. "old
Gong: "This is not the point!" Wife: "Send the bank verification code you just received on your phone."
ok, the arithmetic operators in Python are gone here, ^_^o!
Recommended Posts