Integral type operation, subtraction:
2 + 242*362-11
12/5
2
#假如想要使返回的结果为浮点数, they can be written in the form of floating-point numbers.
12.0/5.0
2.4
Power Index:
3**29
Residual:
22%52
Use type()
functions to view variable types:
A = 1TPE (a) int
Floating point number (float):
A = 1.34type (a) float
Interactive calculation:
1 + 2-(3 * 4/6) * * 5 + 7% 5-27# in Python, precedence is the order of arithmetic, such as "first multiplication plus minus" and "first parentheses" are two priority rules, the priority from high to low ranked as follows: 1. () Brackets 2. * * Power exponential operation 3. *///% multiplication, except, integer division, remainder operation 4. ' +-' plus minus
Integer division, which returns the maximum integer value that is smaller than the result:
12.3//5.2 2.0
Simple Mathematical functions:
Absolute:
ABS (-251.451) 251.451
Rounding:
Round (22.3) 22
Maximum minimum value:
Print min (2, 3, 4, 5) 2print Max (2, 4, 3) 4
Type conversions:
Floating-point integer, which retains only the integral part:
print int (12.324) 12print int (-3.32)-3
In situ calculation:
b = 2.5b + = 2print b4.5b *=29
Boolean type:
A Boolean can be considered a special two-value variable with a value True
of False
:
Q = Truetype (q) BOOLQ = 1 > 2print qfalse
Python----------Digital Foundation