explicitly cast result of math.ceil() to int

avoids TypeError in range()