Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 17 /3 #典型的除法返回一个浮点数
5.666666666666667
>>> 17 // 3 #除法求整
5
>>> 17 % 3 #除法求余
2
>>> 5*3+2 #四则运算
17
>>> 5**2 #平方运算
25
>>> 2**7 #2^7运算
128
>>> width = 20
>>> height = 5 * 9
>>> width * height
900
>>> 3 * 3.75 /1.5 #全浮点运算
7.5
>>> tax = 12.5/100
>>> price = 100.50
>>> price * tax # "_"代表着上一次计算的数据
12.5625
>>> price + _
113.0625
>>> round(_,2) #取小数点后2位精度
113.06
>>>
时间: 2024-10-29 02:59:18