Anonymous user
Boston Python Workshop 7/Friday/Tutorial: Difference between revisions
Boston Python Workshop 7/Friday/Tutorial (view source)
Revision as of 18:42, 2 November 2012
, 11 years ago→Writing Functions
imported>Jesstess |
imported>Jesstess |
||
Line 660:
<b>Step 1: write a function signature</b>
A <b>function signature</b> tells you how the function will be called. It starts with the keyword <code>def</code>, which tells Python that you are defining a function. Then comes a space, the name of your function, an open parenthesis, the comma-separated input <b>
<code>def myFunction():</code>
Line 672:
<code>def myFunction(myList, myInteger):</code>
<b>Step 2: do useful work inside the function</b>
Line 680 ⟶ 678:
Underneath the function signature you do your useful work. Everything inside the function is indented, just like with if/else blocks, so Python knows that it is a part of the function.
You can use the variables passed into the function as
<pre>
|