[英]convert a binary number (consists of the sign, mantissa and exponent ) to decimal number in python
[英]how to decrease the decimal places in the mantissa part of an exponential number in an output in python
编码
avogadro = 6.0225e23 # define Avogadro number
at_wt = 63.55
print ("atomic weight of copper = 63.55")
print("weight of an atom = atomic weight/Avogadro's number")
x = at_wt/ avogadro
print ("Weight of one atom of copper = {}".format(x) )
THE OUTPUT
atomic weight of copper = 63.55
weight of an atom = atomic weight/Avogadro's number
Weight of one atom of copper = 1.0552096305520962e-22
我感兴趣的是在 output 1.0552096305520962e-22 中,我希望指数数的尾数部分只显示 3 个小数点而不是这么多。 因此,我应该使用什么命令来达到预期的结果。
使用更好的格式字符串:
print ("Weight of one atom of copper = {:0.3e}".format(x) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.