+ 2

How to print a float no i.e. 56.0 as 56.00 , 26.5 as 26.50 and 53.45 as 53.45 in python 3

23rd Feb 2019, 5:15 AM
Krishan
Krishan - avatar
3 Réponses
+ 6
f = 26.5 print('%.2f' % f)
23rd Feb 2019, 5:39 AM
Anna
Anna - avatar
+ 3
Here’s a working example for you. The key is Decimal(n).quantize(Decimal(‘1.00’)) https://code.sololearn.com/c66pEm5ok79I/?ref=app
23rd Feb 2019, 5:33 AM
Mike Perkowski
Mike Perkowski - avatar
0
it has hackerRank
19th Jun 2020, 1:20 AM
Jambalsuren Ganbaatar
Jambalsuren Ganbaatar - avatar