I have the radius of a circle and the equation y = int(math.sqrt(pow(radius, 2)-pow(i,2))) (Pythagoras).
Now I want to loop over the range range(-radius,0) + range(1, radius+1) within a multiple of 16 steps like this:
radius = 4
Actually output: -4, -3, -2, 1, 1, 2, 3, 4
What I want: -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4
And I found out, that you can't change the step-size of for-loops easily but I found a way:
print("Length: ", len([x/2 for x in chain(range(-2*radius, 0), range(1,2*radius+1))]))
print("Values: ", [x/2 for x in chain(range(-2*radius, 0), range(1,2*radius+1))])
Which returns 16 and the wanted "count", as I mentioned above.
Now my question is: How can I automate this? Because that it works with 4 is just a "coincidence" and with e.g. radius = 5 it won't work like this. So is there a solution that I can loop through a range in x steps?