+ 3

Anyone can explain print(len(str(float)))

9th Jun 2020, 6:24 PM
Hari Haran
Hari Haran - avatar
5 Answers
+ 6
It takes the name of the float class <class 'float'> Converts to a str value and then prints the length of that string. Which if you count all the characters including the space is 15. Try; print(float) to understand better
9th Jun 2020, 6:31 PM
ChaoticDawg
ChaoticDawg - avatar
+ 6
Thank u @ChaoticDawg and try it print(float)
9th Jun 2020, 6:44 PM
Hari Haran
Hari Haran - avatar
+ 3
Hari Haran I answered that in my previous post. Run print(float) Then count the number of characters that are output including the space. It will equal 15.
9th Jun 2020, 6:36 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Print the length of the string value of a float number 1.342 would be 4 edit: its 5, len takes '.' into account
9th Jun 2020, 6:32 PM
Slick
Slick - avatar
+ 1
@ChaoticDawg How the answer is 15?
9th Jun 2020, 6:34 PM
Hari Haran
Hari Haran - avatar