аватар question@mail.ru · 01.01.1970 03:00

Fixed accuracy

It is necessary to withdraw the number of a type float on the screen with the accuracy of no less n signs after decimalum.
python 3, without the use of libraries.

аватар answer@mail.ru · 01.01.1970 03:00

python 3.6+:

   & gt; & gt; & gt;  a =  2    & gt; & gt; & gt;  n =  3    & gt; & gt; & gt;   f ' {a:. {n}  f}'    '' 2000 '     

or (on earlier versions):

   & gt; & gt;   '{a:. {n} f}' .  format  (**  vars  ())   '2.000'                                        

Latest

Similar