|||
>>> 1+2
3
>>> 9-2
7
>>> 3*5
15
>>> -2**4 # 乘方
-16
# 除法要注意啦
>>> 8/4
2
>>> 8/3
2 # python2
2.6666666666666665 # python3
>>> 8/3. (or 8/3.0 or 8.0/3)
2.6666666666666665
>>> from __future__ import division # python2
>>> 8/3;
2.6666666666666665
>>> 8//3 # // 除法取整数部分
2
>>> 8%5 # 求余数
3
>>> 8%4 # 求余数
0
>>> 8.65%.5 # 求余数
0.15000000000000036
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-2 04:00
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社