码迷,mamicode.com
首页 > 编程语言 > 详细

Python 3 数值计算

时间:2015-08-15 21:18:11      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

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

Python 3 数值计算

标签:

原文地址:http://www.cnblogs.com/xmphoenix/p/4733058.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!