At 08:11 AM 10/16/2005, Norman Silverstone wrote:
>I am an elderly person somewhat physically handicapped with some
>experience  programming in basic and pascal, many years ago. In order to
>keep myself mentally active I decided to have a look once again at
>programming and chose python as a good language to start with. So, I had
>a look at 'Dive into Python', bought a couple of books, 'Python
>Programming for the Absolute Beginner' and 'Learn to program Using
>Python'.
>
>All was well to start with until I came to the section on functions. I
>am finding it very difficult to grasp the reasoning behind the use of
>functions and how and when to use them.

1) did you ever use GOSUB in Basic or procedure or function in Pascal?
    If so, same thing here.

2) functions:
a) as a way to set aside pieces of code `that might otherwise obscure
     an algorithm. For example if I have a complex calculation to do inside
     some loop it may make the program easier to read to put the
     calculation in a function and call the function from w/in the loop.
b) the classical use of functions is to package code that might be
     called from more than one place rather than writing the same code
     twice.
c) in Python (different than Basic or Pascal) functions are objects that
     can be passed around, allowing for things like dictionaries that
     choose which function to use based on some input or condition.
d) in classes functions become methods, a way to evoke a behavior of
    an object.

[snip] 

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

Reply via email to