Thread: def my_abs()?
View Single Post
Old Mar 3rd, 2005, 5:06 PM   #14
Fred
Programmer
 
Fred's Avatar
 
Join Date: Feb 2005
Posts: 67
Rep Power: 4 Fred is on a distinguished road
They are necessary. They are used to pass so called 'arguments'. That is the information, the function needs to wrok. To go back to our 'HelloWorld' function:
def HelloWorld(n): #n is a namespace for an argument
   print 'Hello World' * n
So, now when you type:
HelloWorld(1)
the program prints the message once.
If you type:
HelloWorld(2)
The you get the message twice.

Or if we use our other example and define the function 'walk', you could give the computer the number of steps to go.
Fred is offline   Reply With Quote