Finished "Dive into Python"

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

Finished "Dive into Python"

Post by coldghost213 on Tue Feb 17, 2009 7:49 am
([msg=18073]see Finished "Dive into Python"[/msg])

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
New User
 
Posts: 15
Joined: Wed Jun 25, 2008 9:04 pm
Blog: View Blog (0)


Re: Finished "Dive into Python"

Post by nneonneo on Thu Feb 19, 2009 7:35 pm
([msg=18256]see Re: Finished "Dive into Python"[/msg])

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
New User
 
Posts: 5
Joined: Fri Apr 25, 2008 11:01 am
Blog: View Blog (0)


Re: Finished "Dive into Python"

Post by Defience on Fri Feb 20, 2009 9:21 am
([msg=18283]see Re: Finished "Dive into Python"[/msg])

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!)


:lol: nneonneo....you're too much. Ever think of making some challenges for HTS?
User avatar
Defience
Addict
Addict
 
Posts: 1280
Joined: Thu Jun 12, 2008 3:16 pm
Blog: View Blog (0)



Return to Interpreted Languages

Who is online

Users browsing this forum: No registered users and 0 guests