Boston Python Workshop 6/Friday/Tutorial: Difference between revisions

imported>Jesstess
imported>Adamf
 
(9 intermediate revisions by one other user not shown)
Line 210:
 
===String Concatenation===
 
You can smoosh strings together (called "concatenation") using the '+' sign:
 
<pre>
Line 288 ⟶ 290:
print len("")
fish = "humuhumunukunukuapuaʻa"
length = str(len(fish))
print fish + " is a Hawaiian fish whose name is " + len(fish)length + " characters long."
</pre>
 
Line 361 ⟶ 364:
3.
<pre>
print 2.0 * 123, "2.0" * 123
print 2.0 * 123 + str(2.0) * 123
</pre>
Line 456 ⟶ 458:
</pre>
 
Use <code>==</code> to test for equality. Recall that <code>=</code> is used for <i>assignment</i> (e.g. <code>my_string == "Hello"</code>).
 
This is an important idea and can be a source of bugs until you get used to it: <b>= is assignment, == is comparison</b>.
Line 741 ⟶ 743:
 
Functions don't have to return anything, if you don't want them to. They usually return something because we usually want to be able to assign variables to their output.
 
==Part 2 Practice==
 
[[File:Detective.png|100px]]
 
Learning about functions opens up a whole new way for us to practice, using the programming site codingbat.com. The big goal of this practice section is to get you thinking about how to solve problems in Python.
 
<div style="font-size:125%">[http://codingbat.com/home/bostonpythonworkshop@gmail.com/PythonIntro &raquo; Please visit our CodingBat page and complete tonight's practice problems &laquo;]</div>
 
You don't have to create a CodingBat account to do the exercises, but if you do create an account it'll keep track of which problems you've completed and other statistics.
 
==End of Part 2==
Line 759 ⟶ 751:
 
 
Take a break, stretch, meet some neighbors, and ask the staff if you have any questions about this material. All that's left today is to get checked off, and we'll pick up with more Python fundamentals tomorrow morning.
 
 
Anonymous user