I search some method that said using //
operator, but I didn't understand how to use in my program
def trapezoid(x, a, b, c, d):
if x <= a:
return 0
if a < x <= b:
return (x - a)/(b - a)
if b < x <= c:
return 1
if c < x <= d:
return (d - x)/(d - c)
if d < x:
return 0
for i in range(-100, 100, 0.01):
small_y = trapezoid(i, -2.46, -1.46, 1.46, 2.46)
I tried to use i/0.01 or i//0.01 but show same error, and I don't want to change integer from float, I just want to calculate -100, -99.99, -99.98....