0

I'm learning python from beginning and I don't understand the part where it says {2:.2f}. I know it is related to string format, but no more.

a = int(input('introduce a number: '))
b = int(input('introduce a number: '))

print('the result of {0} divided by {1} is {2:.2f}, and the result of {1} divided by {0} es {3}'.format(a, b, a/b, b/a))

Thanks!

  • This indicates a float rounded by two digits. See more information [here](https://thepythonguru.com/python-string-formatting/) –  Oct 27 '21 at 14:21
  • See also https://stackoverflow.com/questions/8885663/how-to-format-a-floating-number-to-fixed-width-in-python. Note that the "f" you are asking about is a different "f" than the "f" in "f-string". – mkrieger1 Oct 27 '21 at 14:22

1 Answers1

0

it stands for floating point number, which means the amount of digits after the point

Bende
  • 91
  • 8