输入一个小数,输出四舍五入的结果

注意:不能直接使用round()进行处理,具体请百度round()用法

 

方法1:

a =float(input())  #input()是string类型,需要强转

print(int(a)+1 if a-int(a)>=0.5 else int(a)) #int(小数)=小数的整数部分

方法2:

进阶round()方法 --待后续补充

 

posted on 2021-03-07 12:29  jesse_zhao  阅读(383)  评论(0编辑  收藏  举报

导航