range only works with integers. Implement FloatRange(start, stop, step) behaving like a proper read-only sequence:
len(r) is max(0, ceil((stop - start) / step)), computed with a tolerance so FloatRange(0, 1, 0.1) has length 10, not 11r[i] returns start + i * step (no accumulated error), supports negative indices and raises IndexError out of range; slices return a listreversed(), and x in r (true if x is within 1e-9 of an element)step of 0 raises ValueError; negative steps count downUnlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.
Start 7-day free trial