[Tutor] fibonacci.py task ???

bhaaluu bhaaluu at gmail.com
Tue Jun 24 15:34:23 CEST 2008


On Tue, Jun 24, 2008 at 8:47 AM, Danny Laya <danny_laya at yahoo.com> wrote:
> 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.

You can start by using Google  or Wikipedia to get basic definitions of
things like "Fibonacci sequence". It has to do with mathematics or something?
http://www.google.com
http://www.wikipedia.org/

>
> 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.

That is the file extention for a Python Script. The file extension for a BASIC
script is BAS (Fibonacci.bas),  for a Perl script is PL (Fibonacci.pl), for a
Scheme script is SCM (Fibonacci.scm), for a Logo script is LG (Fibonacci.lg)
.................

> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
Kid on Bus: What are you gonna do today, Napoleon?
Napoleon Dynamite: Whatever I feel like I wanna do. Gosh!


More information about the Tutor mailing list