Boston Python Workshop 6/Friday/CodingBat Using Codingbat: Difference between revisions

Content added Content deleted
imported>Jesstess
No edit summary
imported>Jesstess
Line 7: Line 7:
CodingBat is a little different from using Python at the command line or in a text editor like we've been doing. When you use CodingBat, you type your code into a web page and click 'Go' when you want that code to run. You'll still need to make sure you indent all your code to the same level.
CodingBat is a little different from using Python at the command line or in a text editor like we've been doing. When you use CodingBat, you type your code into a web page and click 'Go' when you want that code to run. You'll still need to make sure you indent all your code to the same level.


The way CodingBat works is that your write a function (the first line of the function is written for you), and CodingBat will run your function a few times, each time with a different input. CodingBat will look at the output of your function and compare it to the correct answer. If all the outputs are correct for all the inputs, you're done!
For each CodingBat question, you will write a function. CodingBat will run your function with a few different inputs, and will compare the output of the function you wrote to what it knows is the correct answer. If all the outputs are correct for all the inputs, you've written the function correctly!


We like CodingBat because it gives immediate feedback.
Let's walk through an example; in this case I'll use [http://codingbat.com/prob/p216579 the sumTwoNumbers] exercise.

Let's walk through an example. In this case I'll use [http://codingbat.com/prob/p216579 the sumTwoNumbers] exercise.


Here's the first screen we see:
Here's the first screen we see: