Write a Python program to round a floating-point number to a specified number of decimal places.

Write a Python program to round a floating-point number to a specified number of decimal places.

1
2
3
4
order_amt = 212.374
print('\nThe total order amount comes to %f' % order_amt)
print('The total order amount comes to %.2f' % order_amt)
print()

Final output

Leave a Comment