Finished "Dive into Python"

For the discussion of Perl, Python, Ruby, and PHP and other interpreted languages.

Finished "Dive into Python"

Just a great book for learning python. I am a python newbie (and still consider myself one since the only thing I did was read a book), I want to try making a program or two 1 that would be easy and the other that is a little more advanced before switching to learn C.

I promise I won't bitch and groan
coldghost213
New User

Posts: 15
Joined: Wed Jun 25, 2008 9:04 pm
Blog: View Blog (0)

Re: Finished "Dive into Python"

Mmm...interesting. He wants a challenge

Here's a first warm-up question:

You may, or may not know of the Fibonacci numbers; it's a sequence of numbers f1, f2, f3, ... with f1=f2=1 and f(n) = f(n-1) + f(n-2); Wikipedia explains it best.

Write a Python function (call it "f") to generate the Fibonacci numbers "the obvious way", i.e. according to the definition. Try calculating f(100), and you will see it takes a very long time (don't bother waiting for it -- it would literally take millenia to finish!)

Now, using a Python dictionary, think about how you might go about making this go much faster (and no cheating by using Binet's formula!)
nneonneo
New User

Posts: 5
Joined: Fri Apr 25, 2008 11:01 am
Blog: View Blog (0)

Re: Finished "Dive into Python"

nneonneo wrote:Mmm...interesting. He wants a challenge

Here's a first warm-up question:

You may, or may not know of the Fibonacci numbers; it's a sequence of numbers f1, f2, f3, ... with f1=f2=1 and f(n) = f(n-1) + f(n-2); Wikipedia explains it best.

Write a Python function (call it "f") to generate the Fibonacci numbers "the obvious way", i.e. according to the definition. Try calculating f(100), and you will see it takes a very long time (don't bother waiting for it -- it would literally take millenia to finish!)

Now, using a Python dictionary, think about how you might go about making this go much faster (and no cheating by using Binet's formula!)

nneonneo....you're too much. Ever think of making some challenges for HTS?

Defience

Posts: 1281
Joined: Thu Jun 12, 2008 3:16 pm
Blog: View Blog (0)

Who is online

Users browsing this forum: No registered users and 0 guests