How to set limit in floating value in python .

Here we are going to discuss about how to set limit in floating value i.e- 2.3456566 in this number there are many number after point but if we want only one or two then we can set limit in this number in python by using format() function.

Syntax:-   format( value ,.2f
     here if we want one number after point then write .1f   at  place of .2f  if three then .3f and so on.

Example:-  
x=2.54678
y=format(x,“.2f”)
print(y)

Output:-

2.54

2 thoughts on “How to set limit in floating value in python .

Leave a Reply

Your email address will not be published.