Display float number with 2 decimal places using print()

Python / Fundamentals of Python

892

Given Input:

num = 458.541315

Expected Output:

458.54

Use the %.2f formatting code in print() function to format float number to two decimal places.

Program:

num = 458.541315
print('%.2f' % num)

Output:

58.54

This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.