haibaraxx的个人博客分享 http://blog.sciencenet.cn/u/haibaraxx

博文

Python: operators

已有 2303 次阅读 2016-11-17 19:17 |个人分类:Python|系统分类:科研笔记| operations


>>> 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




https://blog.sciencenet.cn/blog-3031432-1015353.html

上一篇:Matlab: use GSHHS/GSHHG coastline data in M_Map
下一篇:Python 3: Module math - mathematical functions
收藏 IP: 134.1.1.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-2 04:00

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部