Boston Python Workshop 8/Friday/Tutorial: Difference between revisions

Content added Content deleted
imported>Jesstess
imported>Jesstess
Line 84: Line 84:


* Functions are sort of like functions in math class. You provide input to a function and it produces output. The <code>type</code> function takes data as an input, and produces what type of data the data is (e.g. an integer or a float) as output.
* Functions are sort of like functions in math class. You provide input to a function and it produces output. The <code>type</code> function takes data as an input, and produces what type of data the data is (e.g. an integer or a float) as output.
* To use a function, write the name of the function, followed by an open parenthesis, then what the function takes as input (we call that input the <b>arguments</b> to the function), and then a close parenthesis.
* To use a function, write the name of the function, followed by an open parenthesis, then what the function needs as input (we call that input the <b>arguments</b> to the function), and then a close parenthesis.
* Programmers have a lot of slang around functions. They'll say that functions "take" arguments, or that they "give" or "pass" arguments to a function. "call" and "invoke" are both synonyms for using a function.


So in this case 'type' is the name of the function, and it takes one argument; in the example we first give <code>type</code> an argument of 1 and then give it an argument of 1.0.
In the example above, "type" was the name of the function. <code>type</code> takes one argument; we first gave <code>type</code> an argument of 1 and then gave it an argument of 1.0.


===Command history===
===Command history===