format when turning float into string

Solutions on MaxInterview for format when turning float into string by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
showing results for - "format when turning float into string"
Samy
04 Jan 2020
1# Option one
2older_method_string = "%.9f" % numvar
3# Option two, preferred in Python 3
4newer_method_string = "{:.9f}".format(numvar)
5# Option 3 (versions 3.6 and higher)
6newest_method_string = f"{numvar:.9f}"