+ 1

How can we print a specific number of digits after decimal point in python ?

20th Oct 2017, 11:58 AM
Divya Prakash Yadav
Divya Prakash Yadav - avatar
2 Respuestas
+ 1
a=1.47488592 print("%.2f" %a) (for 2 decimal points)
20th Oct 2017, 12:11 PM
Suhi Kun
Suhi Kun - avatar
0
thnx :) . what if we have two numbers say a and b . can we do it like this ? print("{%.2f}{%.2f}".format(a,b))
20th Oct 2017, 12:15 PM
Divya Prakash Yadav
Divya Prakash Yadav - avatar