Format Specifiers
Control width, precision, and alignment.
The format specifier
Inside an f-string or str.format, a colon introduces a format specifier that controls how a value is displayed: {value:spec}.
pi = 3.14159
print(f'{pi:.2f}')Controlling decimal places
.Nf formats a float with exactly N digits after the decimal point, rounding as needed.
value = 2.0 / 3.0
print(f'{value:.3f}')
print(f'{value:.0f}')