format float numbers : Float format : Data Type PYTHON TUTORIALS


PYTHON TUTORIALS » Data Type » Float format »

 

format float numbers


import math
for eachNum in (.2.71.21.7, -.2, -.7, -1.2, -1.7):
    print "int(%.1f)t%+.1f" (eachNum, float(int(eachNum)))
    print "floor(%.1f)t%+.1f" (eachNum, math.floor(eachNum))
    print "round(%.1f)t%+.1f" (eachNum, round(eachNum))
    print '-' 20



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Data Type
» Float format