Jordan B.

asked • 09/23/17

Python decimal question

So this is my code right now:

s = input("Input a float: ")
in_input = float ( s )
'{:{width}.{prec}f}'.format( in_input, width=12, prec=2)
'{0:10.2f}'.format ( in_input )
print (in_input)

It works perfectly, but I need to get the output so that it goes two decimals after the integer and stops. For example, my current code's output is 1234.56789 and 3456.0, I need to get it to say 1234.57 and 3456.00 instead.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.