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

no edit summary
imported>Jesstess
No edit summary
imported>Jesstess
No edit summary
Line 377:
The string manipulate is exactly the same as before. The only difference is that you need to use <b>print</b> to print results to the screen:
 
<code> <code>h + w</code>
 
becomes
 
<code> <code>print(h + w)</code>
 
We'll see more examples of the print function in the next section.
Line 389:
[[File:Treasure_map.png|100px]]
 
Until now we've been executingusing commandsthe at theinteractive Python promptinterpreter. This is great for mathlearning and experimenting, shortbut bitsyou ofcan't code,easily andsave testingor edit your work. For longerbigger ideasprojects, itwe'sll easierwrite toour store thePython code in a file. Let's get some practice with this!
 
<ol>
<li>Download the file http://mit.edu/jesstess/www/BostonPythonWorkshop7BostonPythonWorkshop8/nobel.py by right-clicking on it and saying to save it as a ".py" file to your Desktop. The ".py" extension hints that this is a Python script.</li>
<li>Open a commandterminal prompt, and use the navigation commands (<code>dir</code> and <code>cd</code> on Windows, <code>ls</code>, <code>pwd</code>, and <code>cd</code> on OS X and Linux) to navigate to your home directory. See [[Boston Python Workshop 8/Friday#Goal_.234:_practice_navigating_the_computer_from_a_command_prompt|navigating from a command prompt]] for a refresher on those commands.</li>
<li>Once you are in your homeDesktop directory, execute the contents of <code>nobel.py</code> by typing
 
<pre>
Line 400:
</pre>
 
at athe commandterminal prompt.
 
<code>nobel.py</code> introduces two new concepts: comments and multiline strings.</li>
Anonymous user