Boston Python Workshop 3/Friday/Tutorial: Difference between revisions
Content added Content deleted
imported>Jesstess |
imported>Jesstess |
||
Line 624: | Line 624: | ||
Running this assigns the type of <code>5</code> -- an integer -- to <code>x</code>. |
Running this assigns the type of <code>5</code> -- an integer -- to <code>x</code>. |
||
We also saw the <code>str</code> function, which returns a string representations of an objects so we can print it. For example: |
|||
<pre> |
|||
age = str(23) |
|||
print "I am ", age, "years old." |
|||
</pre> |
|||
We can right our own functions to encapsulate bits of useful work so we can reuse them. Here's how you do it: |
We can right our own functions to encapsulate bits of useful work so we can reuse them. Here's how you do it: |