if statement - Python: How to keep running program until some value becomes 0 and checking how long it takes -


i have following code:

time_counter = 0 in range(time_counter):     if pred > 0:         prey, pred = prey*(1+a-b*pred), pred*1-c+d*prey)     else:         print time_counter     time_counter +=1 

the values a, b, c, , d fixed 0.1, 0.01, 0.01, 0.00009. pred 20 , prey 1000. i'm trying figure out how long takes pred become 0 (as integer, not float) , display time.

logically, can think of starting time @ 0 , running formula...if pred greater 0 repeat , until pred 0 or less 0 stop , display time. not sure doing wrong.

please try keep basic. i'd able using loop conditional statements , using python 2.7 syntax.

edit: sorry if confusing. want count time periods (which in case number of iterations) loop runs until pred equal 0. however, pred should considered 0 once < 1 0.999 0.

here's sloppy answer mobile:

import time  time.time() while (pred > 0):     # smooth jazz time.time() 

apologies if kind of answer bit lacking don't have ide available verify syntax.


Comments

Popular posts from this blog

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

javascript - Create websocket without connecting -

sharepoint - Accessing files across a shared directory using a Windows service -