Python3 round() 函数
Python3 round() 函数
描述
round() 方法返回浮点数x的四舍五入值。
语法
以下是 round() 方法的语法:
round( x [, n] )
参数
- x -- 数字表达式。
- n -- 表示从小数点位数,其中 x 需要四舍五入,默认值为 0。
返回值
返回浮点数x的四舍五入值。
实例
以下展示了使用 round() 方法的实例:
#!/usr/bin/python3 print ("round(70.23456) : ", round(70.23456))
print ("round(56.659,1) : ", round(56.659,1))
print ("round(80.264, 2) : ", round(80.264, 2))
print ("round(100.000056, 3) : ", round(100.000056, 3))
print ("round(-100.000056, 3) : ", round(-100.000056, 3))
以上实例运行后输出结果为:
round(70.23456) : 70
round(56.659,1) : 56.7
round(80.264, 2) : 80.26
round(100.000056, 3) : 100.0
round(-100.000056, 3) : -100.0
Python3 round() 函数的更多相关文章
- python3 的 round 函数的 练习
python3 的 round 函数感觉很别扭,其运算结果与习惯不相符.特记录下来: 代码 ''' python 3的 round 函数 是"四舍六入五成双"的 https://w ...
- (转)Python3的四舍五入round()函数坑爹?不,更科学!
原文:https://blog.csdn.net/lly1122334/article/details/80596026 Python3的四舍五入round()函数坑爹?不,更科学!Python2中, ...
- Python 中关于 round 函数的坑
round函数很简单(而且不需要引入math模块),对浮点数进行近似取值,保留几位小数. 比如 # -*- coding: UTF-8 -*- r1=round(12.12345,3) r2=roun ...
- python中关于round函数的小坑
这个一直都想写,但是因为这个点比较小,所以一直懒得动手.不过还是补上吧,留着早晚是个祸害. round函数很简单,对浮点数进行近似取值,保留几位小数.比如 >>> round(10. ...
- oracle的round函数和trunc函数
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...
- Oracle round函数是什么意思?怎么运用?
如何使用 Oracle Round 函数 (四舍五入) 描述 : 传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果. SELECT ROUND( number, [ decimal_p ...
- oracle round 函数,replace()函数
(1)如何使用 Oracle Round 函数 (四舍五入)描述 : 传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果.SELECT ROUND( number, [ decimal_ ...
- Round函数
Round():函数返回一个数值,舍入到指定的长度或精度 eg: --1) ) ---->123.9990 ) ---->124.0000 --3为需要舍入的位数 --2) ) ----- ...
- Math.Round函数详解
有不少人误将Math.Round函数当作四舍五入函数在处理, 结果往往不正确, 实际上Math.Round采用的是国际通行的是 Banker 舍入法. Banker's rounding(银行家舍入) ...
随机推荐
- 转载:HTuple数据和VC数据的相互赋值
转载来自:http://blog.csdn.net/taily_duan/article/details/51026260 HTuple和VC数据的相互赋值 // HTuple→VC 数据类型转换 H ...
- django之def get_response(self, request):
class BaseHandler(object)方法get_response,控制着处理请求的流程,调用中间件,返回请求. def get_response(self, request): &quo ...
- 白鹭引擎 - 对象的添加与删除 ( 开关效果 addChild, removeChild )
class Main extends egret.DisplayObjectContainer { /** * Main 类构造器, 初始化的时候自动执行, ( 子类的构造函数必须调用父类的构造函数 ...
- hadoop报错:hdfs.DFSClient: Exception in createBlockOutputStream
hadoop跑任务搞的好好的,后来把hadoop-dir移了一个位置,结果报错: java.io.EOFException: Premature EOF: no length prefix avail ...
- VUE.js全局变量的定义
模块化之后,想用js全局变量,遇到点困难.搜索资料后搞定,大概2个步骤: 1.定义一个vue模块,const定义变量,并用export对外暴露. Globle.vue <script> / ...
- 深度学习原理与框架-神经网络-cifar10分类(代码) 1.np.concatenate(进行数据串接) 2.np.hstack(将数据横着排列) 3.hasattr(判断.py文件的函数是否存在) 4.reshape(维度重构) 5.tanspose(维度位置变化) 6.pickle.load(f文件读入) 7.np.argmax(获得最大值索引) 8.np.maximum(阈值比较)
横1. np.concatenate(list, axis=0) 将数据进行串接,这里主要是可以将列表进行x轴获得y轴的串接 参数说明:list表示需要串接的列表,axis=0,表示从上到下进行串接 ...
- AS3 - 对文件和目录的操作
1,写入到文件 1 2 3 4 5 var fileObj:File = File.documentsDirectory.resolvePath("hangge.txt"); va ...
- css3 - 特性
伪类选择器 伪类选择器,不用再使用js来控制奇偶不同了 tr:nth-child(even){ background-color: white; } tr:nth-child(odd){ backgr ...
- data型怎么转换格式
data型如何转换格式01-1月 -03 如何转成 YYYY-MM-DD 的格式 本来就是date了 ------解决方案--------------------to_char ...
- adb push和adb install区别
一般的,Android 应用程序有两种安装方法: 1. 将应用程序的apk文件push到手机中,用如下命令: adb push xxxx.apk /system/app. 2. 用adb instal ...