python怎么进行小数的四则运算?并且可以自己定义小数点位数?我现在只会整数的四则运算,如下:a= int(raw_input('please input number1:'))b= int(raw_input('please input number2:'))print "the + of the result is:%s\n\the -

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/19 04:11:05
python怎么进行小数的四则运算?并且可以自己定义小数点位数?我现在只会整数的四则运算,如下:a= int(raw_input('please input number1:'))b= int(raw_input('please input number2:'))print
xJ@_eJME@$Ee!ъ(mn"6mk}L╯$QoVhn s9>Bc2Ӷ6 6TĻ `C߿_k+]IMz;py q[pU!gPQ19oolrq$cCF )-I8K󐙀tEsSFH-`Fdz"J/;a"B|~Q\e4 >c^x%6Gad8f_G5{iïyUHh.J&KtڑBI&|;drDxN.-691u}cpǴRKK zbBuAY;V́ik43Le?dK2Ɍ#֞NS(VrXY

python怎么进行小数的四则运算?并且可以自己定义小数点位数?我现在只会整数的四则运算,如下:a= int(raw_input('please input number1:'))b= int(raw_input('please input number2:'))print "the + of the result is:%s\n\the -
python怎么进行小数的四则运算?并且可以自己定义小数点位数?
我现在只会整数的四则运算,如下:
a= int(raw_input('please input number1:'))
b= int(raw_input('please input number2:'))
print "the + of the result is:%s\n\
the - of the result is:%s\n\
the * of the result is:%s\n\
the / of the result is:%s"%(a+b,a-b,a*b,a/b)
因为int是整数,我不知道怎么进行小数的运算,求教!

python怎么进行小数的四则运算?并且可以自己定义小数点位数?我现在只会整数的四则运算,如下:a= int(raw_input('please input number1:'))b= int(raw_input('please input number2:'))print "the + of the result is:%s\n\the -
什么意思? 你将a 、b定义为float型不就可以了吗?
fromat()比%格式化输出强悍,最好学会用format格式化:
如保留2位小数:'{0:0.2}.format(1.2/7) ===0.17