
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

import simplegui
result = 1 iteration = 0 max_iterations = 10
def init(start): """Initializes n.""" global n n = start print "Input is", n
def get_next(current): """??? Part of mystery computation.""" return 0.5 * (current + n / current)
def update(): """??? Part of mystery computation.""" global iteration, result iteration += 1
if iteration >= max_iterations: timer.stop() print "Output is", result else: result = get_next(result)
timer = simplegui.create_timer(1, update)
init(1024) timer.start()