The Python Oracle

Convert floating point number to a certain precision, and then copy to string

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Fantascape Looping

--

Chapters
00:00 Question
00:50 Accepted answer (Score 242)
02:07 Answer 2 (Score 76)
03:03 Answer 3 (Score 61)
03:16 Answer 4 (Score 12)
03:32 Thank you

--

Full question
https://stackoverflow.com/questions/1526...

Accepted answer links:
[preferred]: http://docs.python.org/2/library/stdtype...
[this link on string formatting from the Python documentation]: http://docs.python.org/2/library/string....
[this link will suffice and has info on the various flags]: http://docs.python.org/2/library/stdtype...
[see more information here]: https://docs.python.org/3.6/reference/le...

Answer 2 links:
[f-string]: https://docs.python.org/3/whatsnew/3.6.h...
[What's new in Python 3.6]: https://docs.python.org/3/whatsnew/3.6.h...
[PEP official documentation]: https://www.python.org/dev/peps/pep-0498/
[Python official documentation]: https://docs.python.org/3/reference/lexi...
[Really good blog post - talks about performance too]: https://cito.github.io/blog/f-strings/
[image]: https://i.stack.imgur.com/azP5N.png

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #string #floatingpoint

#avk47