[Tutor] Fw: loops

Richard Hultgren hultgren1946 at yahoo.com
Tue Dec 8 16:36:08 CET 2009





----- Forwarded Message ----
From: Richard Hultgren <hultgren1946 at yahoo.com>
To: tutor at python.org
Sent: Mon, December 7, 2009 2:53:40 PM
Subject: loops
I'm quite new but determined.  Can you explain to me, step by step, what is going on in the computer in this loop.  I hope I am not being too dumb!


a = 0
b = 1
count = 0
max_count = 20
while count < max_count:
    count = count + 1
    # we need to keep track of a since we change it
    old_a = a                # especially here
    old_b = b
    a = old_b
    b = old_a + old_b
    # Notice that the , at the end of a print statement keeps it
    # from switching to a new line
    print old_a,


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091208/5a05de18/attachment.htm>


More information about the Tutor mailing list