[Tutor] fibonacci.py task ???

Danny Laya danny_laya at yahoo.com
Tue Jun 24 14:47:29 CEST 2008


Hi all, can you explain me what this code mean :

Fibonacci.py
  
# This program calculates the Fibonacci sequence
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
    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,


 Output:
 
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181

Do you understand it ??? Can you explain me....ahhh.... you know
i'm a newbie so please explain it with a simple expalanation.

And I got many tutorial with title *.py(e.g: Fibonacci.py and Password.py),
can you explain me what *.py mean? Thank's for helping me.


       
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080624/435b7e80/attachment.htm>


More information about the Tutor mailing list