NumerApprox Module LoopDemo2 (py)

# All lines like this one that begin with a "#" are comments.
# All other non-blank lines are program statements.

# Import the visual library.
from visual import *

# Set the time
t = 0

# Set the timestep
dt = 1

# Print the current value of the time
print t

# The next line causes the indented lines that follow
# it to be repeatedly executed in the loop. The construct:
#   1==1
# means "is one is equal to one?" which is always true.
# Thus double equal signs like this mean something different
# than a single equal sign, such as is used above to set the
# values of the time and the timestep.
while 1==1:

    # Do one calculation every second
    rate(1)

    # Increment the value of the time and print the result.
    # Here the single equal sign means set the value of t to
    # whatever appears to the right of the equal sign.
    t = t + dt
    print t
# End of the while loop. Go back to the rate(1) statement and
# start over.