If i consider the following floating point number:  135.12345678910 and if i want to concatenate that value to a string, but only till 135.123456789. With print, I can easily do this by doing something like:

print "%.9f" % numvar
with numvar being my original number. Is there an easy way to do this?

Oct 18, 2018 in Python 544 views

## 1 answer to this question.

With Python < 3 (e.g. 2.6 [see comments] or 2.7), there are two ways to do so.

# Option one
older_method_string = "%.9f" % numvar

# Option two
answered Oct 18, 2018 by
• 13,300 points

## How to round a floating point number up to certain decimal place in Python?

This is normal (and has nothing to do ...READ MORE

## how to find factorial of a number?

You can find factorial by many ways. ...READ MORE

## How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

## how do i use the enumerate function inside a list?

Enumerate() method adds a counter to an ...READ MORE