You can use variables in the formats.
>>> flt = 1.2345
>>> two = 2
>>> f"{flt:.{two}f}"
'1.23' >>> flt = 1.2345
>>> two = 2
>>> f"{flt:.{two}f}"
'1.23' greet = lambda x: f"hello {x}"