如何在range()函数中包含上限?因为我的for循环看起来像我不能加1:包含范围上限()
for x in range(1,math.floor(math.sqrt(x))):
y = math.sqrt(n - x * x)
但据我了解它实际上是1 < x < M
我需要1 < x <= M
添加1将彻底改变结果。 我想重写我的旧程序从C#到Python。这就是它的样子在C#:
for (int x = 1; x <= Math.Floor(Math.Sqrt(n)); x++)
double y = Math.Sqrt(n - x * x);
都没有。 '范围'给你'1 <= x
dan04
2010-05-07 04:49:15