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

Content added Content deleted
imported>Jesstess
imported>Jesstess
No edit summary
Line 81: Line 81:
So now we've seen two data types: <b>integers</b> and <b>floats</b>.
So now we've seen two data types: <b>integers</b> and <b>floats</b>.


By the way, what is a "function"? Here are the important ideas about functions:
I used the term 'function' without explaining what it is -- we'll talk about functions more in a bit, and write our own, but for now know these things:


* Functions encapsulate some useful bit of work. We save that useful bit of work inside the function so we don't have to type it over and over again every time we want to use it. So, for example, some nice person decided that being able to determine the type of an object was useful, so he or she put the Python code that figures out an object's type into the function <code>type</code>, and now we all get to use it, instead of having to write it ourselves.
* Functions encapsulate some useful bit of work. We save that useful bit of work inside the function so we don't have to type it over and over again every time we want to use it. So, for example, some nice person decided that being able to determine the type of an object was useful, so he or she put the Python code that figures out an object's type into the function <code>type</code>, and now we all get to use it, instead of having to write it ourselves.