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)
Asked
Active
Viewed 32 times
0

Toto
- 89,455
- 62
- 89
- 125
-
4Does this answer your question? [How do I do exponentiation in python?](https://stackoverflow.com/questions/30148740/how-do-i-do-exponentiation-in-python) – Nick is tired Jun 22 '21 at 14:06
1 Answers
3
Add print(total)
to your loop and the answer will become clear. Always check values if things aren't doing what you expect. It's easy to do and will often give you the answer immediately.
I suspect the core of your problem is that you expected ^
to be the exponentiation operator, while it's actually **
.

Kemp
- 3,467
- 1
- 18
- 27