Anonymous user
Boston Python Workshop 3/Friday/Tutorial: Difference between revisions
Boston Python Workshop 3/Friday/Tutorial (view source)
Revision as of 02:25, 17 June 2011
, 13 years ago→Writing Functions
imported>Jesstess |
imported>Jesstess |
||
Line 744:
</pre>
if <code>number</code> is less than 0, you return <code>number * -1</code> and never even get to the last line of the function. However, if <code>number</code> is greater than or equal to 0, the <code>if</code> expression evaluates to <code>False</code>, so we skip the code in the <code>if</code> block and return <code>number</code>.
We could have written the above function like this if we wanted. It's the same logic, just more typing:
<pre>
|