Re: [Tutor] Tutor Digest, Vol 52, Issue 66

2008-06-24 Thread kinuthiA muchanE

On Tue, 2008-06-24 at 15:26 +0200, [EMAIL PROTECTED] wrote:
 Message: 5
 Date: Tue, 24 Jun 2008 05:47:29 -0700 (PDT)
 From: Danny Laya [EMAIL PROTECTED]
 Subject: [Tutor] fibonacci.py task ???
 To: tutor@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=iso-8859-1
 
 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 meahhh 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.
 
If you have an algorithm to calculate the sum of exactly two(!) numbers
you could do it in  the Python prompt by:

 3+4
7


... or you could start you fire up a text editor (something like Notepad
in Windows, or nano in Linux and type 3+4(without the quotes!),
hmmm..., and save the file as anything you want, lets say for  now you
save the file as threePlusFour. Every time you invoke the python
interpreter (do you know how to do that?) with threePlusFour, you will
get the value seven! 

Because there are many programming languages, such as C, java, perl,
ruby, haskell(!), you might want to be more specific as to what
programming language you save saved your code in. .c for C, .rb for
Ruby, .java for java and, of course .py for python. 

... or you could define a function...

One of the indefatigable contributors to this mailing list, Alan Gauld
(where do you get the time?), has an excellent tutorial for beginners.
Check it out at http://www.freenetpages.co.uk/hp/alan.gauld (correct?)

Kinuthia... 




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 52, Issue 66

2008-06-24 Thread Alan Gauld

kinuthiA muchanE [EMAIL PROTECTED] wrote

... or you could start you fire up a text editor (something like 
Notepad

in Windows, or nano in Linux and type 3+4(without the quotes!),


Actually it would need to be

print 3+4

otherwise Python would silently evaluate the expression but
not display the result.

One of the indefatigable contributors to this mailing list, Alan 
Gauld

(where do you get the time?),


With increasing difficulty! :-)

Check it out at http://www.freenetpages.co.uk/hp/alan.gauld 
(correct?)


Correct, thanks for the plug!

Sadly it will need to move soon since Freenet have
announced that they will soon be decommissioning
their free web site(*). I'm trying to decide whether to go to
another free site or spend the money for a proper
hosted site with dedicated domain name etc...

(*) They have already blocked ftp so I can't post updates
anymore :-(

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor