Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Placeholders
Numbers
8. Extended float placeholders—limiting only the decimal part
Date and time
Padding and Alignment
Summary

Instruction

Perfect! In the previous exercise, we set a limit for the entire number. However, in real life, we often only want to limit the decimal part. Take a look:

exact_sum = 126753.762386
print('The amount payable is {:.2f}.'.format(exact_sum))

Result: The amount payable is 126753.76.

Here, the {:.2f} means, "Print the digits before the decimal point as they are, but allow only two digits after the decimal point."

Exercise

You are given a list with daily transaction figures that have very high precision. Print each figure on a new line with only two digits after the decimal point.

Stuck? Here's a hint!

Use {:.2f} to get two digits after the decimal point.