Code in full;
import math maxValue = 415.2 integerPart = str(maxValue).split('.')[0] # selects the integer part integerLength = len(integerPart) if integerLength == 1: n = 1 elif integerLength == 2: n = 10 elif integerLength == 3: n = 100 elif integerLength == 4: n = 1000 elif integerLength == 5: n = 10000 else: n = 100000 maxValueAdd = float(maxValue) + n + 0.1 # n allows for a value to be returned that is higher by the same factor d = int(math.ceil(maxValueAdd)) # calculates the upper bound and returns an integer print "Maximum value = {}".format(maxValue) print "Y axis maximum = {}".format(d)