print("{:.1f}".format(number)) # Python3
print "%.1f" % number # Python2
# round a value to 2 decimal points
value_to_print = 123.456
print(f'value is {round(value_to_print, 2)}')
# prints: value is 123.46
# Python code to demonstrate precision
# and round()
# initializing value
a = 3.4536
# using "%" to print value till 2 decimal places
print("The value of number till 2 decimal place(using %) is : ", end="")
print('%.2f' % a)
# using format() to print value till 3 decimal places
print("The value of number till 3 decimal place(using format()) is : ", end="")
print("{0:.3f}".format(a))
# using round() to print value till 2 decimal places
print("The value of number till 2 decimal place(using round()) is : ", end="")
print(round(a, 2))