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 37: Line 37:




Let's add some code. Remember that you just need to write the body of the function, but you still need to indent. Here's a first try at the problem:
Let's add some code. The '''function signature''' has already been written for you. You'll write the rest of the function -- remember to indent everything inside the function!



[[File:Cbat_wrong.png|border|center]]
[[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. Maybe instead of <code>return</code> I should use <code>print</code>?



[[File:Cbat_print.png|border|center]]
[[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>:
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>:



[[File:Cbat_correct.png|border|center]]
[[File:Cbat_correct.png|border|center]]



Great!
Great!