+ 2
print(format (float(5)/float(3), '.3' )) there output comes 1.67 if i am use , '.3f' then output comes 1.667.
so what is the roll of "f" in this tell me plz ?????
2 odpowiedzi
+ 5
VɪsʜᴀL ,
'f' is a format specifier for float numbers, '3' means that the output shows 3 digits from decimal places.
to get more familiar with output formating, you can read this tutorial:
https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-f-strings/
+ 1
When dealing with floats
The format ".3" means:
there shell be displayed 3 digits at most
The format ".3f" means:
the number is to be shown in fixed point notation with a precision of 3 digits after the point
P. S.: learn f-strings, they're much easier to read