Python f-strings can do more than you thought. f'{val=}', f'{dt:%Y-%m-%d}'
youtube.com
youtube.com
Note: I'm trying a more informal style in this video so make sure to let me know if you like it better this way, as opposed to my usual cut-after-every-sentence editing.
>>> import math
>>> num_value = math.pi # to get long fractional part
>>> precision = 2
>>> print(f'{num_value:.{precision}f}')
3.14
>>> precision = 5
>>> print(f'{num_value:.{precision}f}')
3.14159