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

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


<pre>
<pre>
length = len("Mississippi")
x = type(5)
</pre>
</pre>


Running this assigns the type of <code>5</code> -- an integer -- to <code>x</code>.
Running this assigns the length of the string "Mississippi" to the variable <code>length</code>.


We can write our own functions to encapsulate bits of useful work so we can reuse them. Here's how you do it:
We can write our own functions to encapsulate bits of useful work so we can reuse them. Here's how you do it: