total = 0
k = 0
while total < 2000:
k += 1
total = 10*k^2-4*k+2+total
print("The number of terms is:", k)
print("The sum is: ", total)发布于 2021-06-22 22:06:55
将print(total)添加到您的循环中,答案将变得清晰。如果事情没有像你期望的那样做,一定要检查这些值。这很容易做到,而且通常会立即给你答案。
我怀疑你的问题的核心是你期望^是指数运算符,而它实际上是**。
https://stackoverflow.com/questions/68084990
复制相似问题