Python float to percentage: Format with % in an f-string

Python float to percentage: Format with % in an f-string

Have a Python float, and want to show it as a percentage? Use % in an f-string

x = .023
print(f'{x:.2%}')  # 2.30%
x = .02375
print(f'{x:.2%}')  # 2.38% -- rounds!
x = 1.02375
print(f'{x:.2%}')  # 102.38%