Rounding floats with f-string [duplicate] December 18, 2022 by Tarik How about this x = 3.14159265 print(f'pi = {x:.2f}') Docs for f-strings