gen
gen

Reputation: 10040

python function to set accuracy of float

I would like to make a function:

def accuracy(number, index):

For example

Upvotes: 2

Views: 654

Answers (1)

Paul Evans
Paul Evans

Reputation: 27567

def accuracy(n, i):
    return round(float(n) / 10**i) * 10**i

Upvotes: 3

Related Questions