Boston Python Workshop 6/Friday/CodingBat Using Codingbat: Difference between revisions
Content added Content deleted
imported>Jesstess No edit summary |
imported>Jesstess No edit summary |
||
Line 43: | Line 43: | ||
Hmm. I've got one correct and two wrong. |
Hmm. I've got one correct and two wrong. Oh! I see - I typed in <code>first</code> twice, when instead I should have used <code>second</code>: |
||
[[File:Cbat_print.png|border|center]] |
|||
That's not it. CodingBat problems always want you to use <code>return</code> in your functions. Oh! I see - I typed in <code>first</code> twice, when instead I should have used <code>second</code>: |
|||
Line 56: | Line 50: | ||
Great! |
Great! |
||
I can check this by typing the same function into the command prompt: |
|||
What CodingBat is doing is the same as when you write a function in your editor or at the |
What CodingBat is doing is the same as when you write a function in your text editor or at the Python prompt and then run it a few times, like this: |
||
<pre> |
<pre> |
||
awf$ python |
|||
Python 2.6.1 (r261:67515, Aug 2 2010, 20:10:18) |
|||
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin |
|||
Type "help", "copyright", "credits" or "license" for more information. |
|||
>>> def sumTwoNumbers(first, second): |
>>> def sumTwoNumbers(first, second): |
||
... return first + second |
... return first + second |
||
Line 78: | Line 66: | ||
</pre> |
</pre> |
||
Perfect! |
Perfect! |
||
<div style="font-size:125%">[http://codingbat.com/home/bostonpythonworkshop@gmail.com/PythonIntro Now we can move on to completing tonight's practice problems]</div> |
<div style="font-size:125%">[http://codingbat.com/home/bostonpythonworkshop@gmail.com/PythonIntro Now we can move on to completing tonight's practice problems]</div> |