Anonymous user
Boston Python Workshop 6/Friday/CodingBat Using Codingbat: Difference between revisions
Boston Python Workshop 6/Friday/CodingBat Using Codingbat (view source)
Revision as of 02:43, 30 March 2012
, 12 years ago→Using CodingBat
imported>Jesstess No edit summary |
imported>Adamf |
||
(9 intermediate revisions by one other user not shown) | |||
Line 1:
We are going to use a website called [http://codingbat.com/home/bostonpythonworkshop@gmail.com/PythonIntro CodingBat.com] to practice Python throughout this workshop.
Before you do the CodingBat questions for the Friday tutorial, let's walk through how to use CodingBat.com with an example.
Line 11:
We like CodingBat because it gives you immediate feedback on how close your function is to being correct.
Let's walk through an example
If you visit that exercise web page, this is what you'll see:
Line 23:
This screen:
# describes the problem (write a function to add any two numbers together)
# shows you some of the inputs that CodingBat will use to test the function you've written, and the outputs that CodingBat expects to see returned from your function for each input.
The inputs are the values in the parentheses, and the expected output is the value pointed to by the arrows:
Line 31:
If you simply click "Go" without typing anything in the box,
Line 37:
Let's add some code.
[[File:Cbat_wrong.png|border|center]]
Hmm. I've got one correct and two wrong. Maybe instead of <code>return</code> I should use <code>print</code>?▼
▲Hmm. I've got one correct and two wrong.
[[File:Cbat_correct.png|border|center]]
Great! All the tests are green, so we know that we've done this problem correctly and can move on to the next one.
What CodingBat is doing is the same as when you write a function in your text editor or at the
▲What CodingBat is doing is the same as when you write a function in your editor or at the command prompt and run it a few times, like this:
<pre>
>>> def sumTwoNumbers(first, second):
... return first + second
Line 72 ⟶ 65:
</pre>
Perfect!
Now that you are a CodingBat master:
<div style="font-size:125%">[http://codingbat.com/home/bostonpythonworkshop@gmail.com/
|