python f string number of decimals code example
Example 1: f string decimal places
>>> a = 10.1234
>>> f'{a:.2f}'
'10.12'
Example 2: python f-string padding
#!/usr/bin/env python3
name = 'Peter'
age = 23
print('%s is %d years old' % (name, age))
print('{} is {} years old'.format(name, age))
print(f'{name} is {age} years old')