-1

I have to convert this value to 23.69 or 23.70 not like that talll number 23.69098712446352

a=552.0
b=23.3
c=a/b
print(c)
Anand S Kumar
  • 82,977
  • 18
  • 174
  • 164
Ammar Alyasry
  • 106
  • 1
  • 5

3 Answers3

0

str.format the output:

print("{:.2f}".format(c))

Or round:

round(c, 2)

Output:

In [9]: print(c)
23.6909871245

In [10]: print("{:.2f}".format(c))
23.69
In [11]: print(round(c, 2))
23.69
Padraic Cunningham
  • 168,988
  • 22
  • 228
  • 312
0

Use round function -

c = round(a/b , 2)
Anand S Kumar
  • 82,977
  • 18
  • 174
  • 164
0

Two ways: round(a.b, 2)

Or just for display use this:

>>> "%.2f" % 3.14159
'3.14'
>>> print("%.2f" % a)
sinhayash
  • 2,483
  • 4
  • 16
  • 48