0
len(str(3.154155151000)) #11 ???
len(str(154155151000))  #12

In my opinion, the answer of len(str(3.154155151000)) would be 14. I thought the answer is 14 that might be include 3 and point. But the actual result is 11 How could it be 11?

merv
  • 67,214
  • 13
  • 180
  • 245
pineapple
  • 15
  • 3

1 Answers1

5

The parameters passed into a method gets evaluated before they enter the method. So the 3.154155151000 gets evaluated before str(3.154155151000), hence 3.154155151000 becomes just 3.154155151 by the time it gets converted to a string.

Red
  • 26,798
  • 7
  • 36
  • 58