I have a function taking float arguments (generally integers or decimals with one significant digit), and I need to output the values in a string with two decimal places (5
String formatting:
print "%.2f" % 5
If you want to get a floating point value with two decimal places limited at the time of calling input,
Check this out ~
a = eval(format(float(input()), '.2f')) # if u feed 3.1415 for 'a'.
print(a) # output 3.14 will be printed.
Shortest Python 3 syntax:
n = 5
print(f'{n:.2f}')
Using Python 3 syntax:
print('%.2f' % number)
Since this post might be here for a while, lets also point out python 3 syntax:
"{:.2f}".format(5)