13,420
edits
Changes
→PART 3 - String Formatting Advanced Features
print('{0:f}'.format(number2)) # A colon separate the position/index areas from the extra functionality
print('{0:f}'.format(number3)) # "f" represents the fixed point number
</source>:#Notice that there are many decimal places after this number. This makes the number look "ugly". We need to further format the number to indicate the number of decimal places (or no decimal places if number is an integer). A fixed point number means that it can control the number of digits that come after the decimal point, try changing the '''.2''' to any other number and experiment.:#Issue the following to demonstrate:<source>
print('{0:.0f}'.format(number1)) # Show no digits after decimal point
print('{0:.2f}'.format(number2)) # Show two digits after decimal point