Rolling summation.
Determine the terminal value of y
. While y
is less than the threshold, add 0.01*(−2)
to the old value of y
.
y = 0.1
threshold = .11
I tried this.
while y < threshold:
if True:
print(y+ 0.01*(y-y**2))
else:
break
Why did nothing run when i tried this?
If your intent is to start with y = 0.1
, and then continuously update y
by adding the value of 0.01*(yy**2)
to the current value of y until it equals or exceeds the value of threshold = 0.11
, the following code accomplishes this. If your intent is otherwise, please specify.
y = 0.1
threshold = .11
while y < threshold:
y += 0.01*(y-y**2)
print(y)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.