![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
Quote:
![]() |
|
|
|
|
|
|
#12 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
ok....
'def' assigns a certain process to a name. Just like naming this 'foot in front of the other foot' walking. You just say def and the the name. The you press ':' this sign and press enter. And the you kust tell the computer what to do, everytime you say the name. The easiest example of them all: def HelloWorld(): print 'Hello World' And that is it. So now, everytime in your program, whwn you type 'HelloWorld', a message appears, saying 'Hello World'... Not that hard, is it??? Hope this helpsFred |
|
|
|
|
|
#13 |
|
Programmer
Join Date: Feb 2005
Posts: 86
Rep Power: 0
![]() |
ok
that helped you said it in simpler terms but are the "()" necessary at the end? and what is the point of putting something in the bracket? |
|
|
|
|
|
#14 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
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 HelloWorld(1) If you type: HelloWorld(2) Or if we use our other example and define the function 'walk', you could give the computer the number of steps to go. |
|
|
|
|
|
#15 |
|
Programmer
Join Date: Feb 2005
Posts: 86
Rep Power: 0
![]() |
you have to explain it to me a little simpler
what does print 'Hello World' * n it multiplies 'helloworld' by n but what is "n"? Last edited by arod199113; Mar 3rd, 2005 at 6:10 PM. |
|
|
|
|
|
#16 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
Did you take math in school???
n can be any natural number. Meaning, that it can be any number without desmos or fractions which is bigger than 0. In other words, n is a variable. It is the number, which you put into the brackets, when you call the function (when you apply the prcess). I strongly advise reading this tutorial: http://www.ibiblio.org/obp/thinkCSpy/chap03.htm (functions in general) and http://www.ibiblio.org/obp/thinkCSpy/chap05.htm (useful functions and how to apply them) |
|
|
|
|
|
#17 |
|
Programmer
Join Date: Feb 2005
Posts: 86
Rep Power: 0
![]() |
i understand math
i just dont cant understand functions in python math != python math <= python |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|