First time here? Check out the FAQ!
def Ns(x, nd = 5): # round x to a given number of significant digits d = ceil(log(abs(x), 10)) return round(x, ndigits = -d + nd)