index.html 27.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="last-modified" content="2017-08-04 00:20:27 +0200">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- meta "search-domain" used for google site search function google_search() -->
    <meta name="search-domain" value="/swc-releases/2017.08/python-novice-inflammation">
    <link rel="stylesheet" type="text/css" href="../assets/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../assets/css/bootstrap-theme.css" />
    <link rel="stylesheet" type="text/css" href="../assets/css/lesson.css" />
    
    <link rel="shortcut icon" type="image/x-icon" href="/favicon-swc.ico" />
    
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
    <title>Programming with Python</title>
  </head>
  <body>
    <div class="container">
      
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>

      
      

      
      <a class="navbar-brand" href="../">Home</a>

    </div>
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">

	
        <li><a href="../conduct/">Code of Conduct</a></li>

	
        
        <li><a href="../setup/">Setup</a></li>
        <li class="dropdown">
          <a href="../" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Episodes <span class="caret"></span></a>
          <ul class="dropdown-menu">
            
            <li><a href="../01-numpy/">Analyzing Patient Data</a></li>
            
            <li><a href="../02-loop/">Repeating Actions with Loops</a></li>
            
            <li><a href="../03-lists/">Storing Multiple Values in Lists</a></li>
            
            <li><a href="../04-files/">Analyzing Data from Multiple Files</a></li>
            
            <li><a href="../05-cond/">Making Choices</a></li>
            
            <li><a href="../06-func/">Creating Functions</a></li>
            
            <li><a href="../07-errors/">Errors and Exceptions</a></li>
            
            <li><a href="../08-defensive/">Defensive Programming</a></li>
            
            <li><a href="../09-debugging/">Debugging</a></li>
            
            <li><a href="../10-cmdline/">Command-Line Programs</a></li>
            
	    <li role="separator" class="divider"></li>
            <li><a href="../aio/">All in one page (Beta)</a></li>
          </ul>
        </li>
	

	
	
        <li class="dropdown">
          <a href="../" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Extras <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="../reference/">Reference</a></li>
            
            <li><a href="../about/">About</a></li>
            
            <li><a href="../discuss/">Discussion</a></li>
            
            <li><a href="../figures/">Figures</a></li>
            
            <li><a href="../guide/">Instructor Notes</a></li>
            
          </ul>
        </li>
	

	
        <li><a href="../license/">License</a></li>
	
	<li><a href="/edit/gh-pages/reference.md">Improve this page <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a></li>
	
      </ul>
      <form class="navbar-form navbar-right" role="search" id="search" onsubmit="google_search(); return false;">
        <div class="form-group">
          <input type="text" id="google-search" placeholder="Search..." aria-label="Google site search">
        </div>
      </form>
    </div>
  </div>
</nav>


<h1 class="maintitle"><a href="../">Programming with Python</a></h1>


<h2>Key Points</h2>
<table class="table table-striped">

  
    <tr>
      <td class="col-md-3">
        <a href="../01-numpy/">Analyzing Patient Data</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>Import a library into a program using <code class="highlighter-rouge">import libraryname</code>.</p>
</li>
        
        <li><p>Use the <code class="highlighter-rouge">numpy</code> library to work with arrays in Python.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">variable = value</code> to assign a value to a variable in order to record it in memory.</p>
</li>
        
        <li><p>Variables are created on demand whenever a value is assigned to them.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">print(something)</code> to display the value of <code class="highlighter-rouge">something</code>.</p>
</li>
        
        <li><p>The expression <code class="highlighter-rouge">array.shape</code> gives the shape of an array.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">array[x, y]</code> to select a single element from a 2D array.</p>
</li>
        
        <li><p>Array indices start at 0, not 1.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">low:high</code> to specify a <code class="highlighter-rouge">slice</code> that includes the indices from <code class="highlighter-rouge">low</code> to <code class="highlighter-rouge">high-1</code>.</p>
</li>
        
        <li><p>All the indexing and slicing that works on arrays also works on strings.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge"># some kind of explanation</code> to add comments to programs.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">numpy.mean(array)</code>, <code class="highlighter-rouge">numpy.max(array)</code>, and <code class="highlighter-rouge">numpy.min(array)</code> to calculate simple statistics.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">numpy.mean(array, axis=0)</code> or <code class="highlighter-rouge">numpy.mean(array, axis=1)</code> to calculate statistics across the specified axis.</p>
</li>
        
        <li><p>Use the <code class="highlighter-rouge">pyplot</code> library from <code class="highlighter-rouge">matplotlib</code> for creating simple visualizations.</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../02-loop/">Repeating Actions with Loops</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>Use <code class="highlighter-rouge">for variable in sequence</code> to process the elements of a sequence one at a time.</p>
</li>
        
        <li><p>The body of a <code class="highlighter-rouge">for</code> loop must be indented.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">len(thing)</code> to determine the length of something that contains other values.</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../03-lists/">Storing Multiple Values in Lists</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p><code class="highlighter-rouge">[value1, value2, value3, ...]</code> creates a list.</p>
</li>
        
        <li><p>Lists are indexed and sliced in the same way as strings and arrays.</p>
</li>
        
        <li><p>Lists are mutable (i.e., their values can be changed in place).</p>
</li>
        
        <li><p>Strings are immutable (i.e., the characters in them cannot be changed).</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../04-files/">Analyzing Data from Multiple Files</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>Use <code class="highlighter-rouge">glob.glob(pattern)</code> to create a list of files whose names match a pattern.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">*</code> in a pattern to match zero or more characters, and <code class="highlighter-rouge">?</code> to match any single character.</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../05-cond/">Making Choices</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>Use <code class="highlighter-rouge">if condition</code> to start a conditional statement, <code class="highlighter-rouge">elif condition</code> to provide additional tests, and <code class="highlighter-rouge">else</code> to provide a default.</p>
</li>
        
        <li><p>The bodies of the branches of conditional statements must be indented.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">==</code> to test for equality.</p>
</li>
        
        <li><p><code class="highlighter-rouge">X and Y</code> is only true if both <code class="highlighter-rouge">X</code> and <code class="highlighter-rouge">Y</code> are true.</p>
</li>
        
        <li><p><code class="highlighter-rouge">X or Y</code> is true if either <code class="highlighter-rouge">X</code> or <code class="highlighter-rouge">Y</code>, or both, are true.</p>
</li>
        
        <li><p>Zero, the empty string, and the empty list are considered false; all other numbers, strings, and lists are considered true.</p>
</li>
        
        <li><p>Nest loops to operate on multi-dimensional data.</p>
</li>
        
        <li><p>Put code whose parameters change frequently in a function, then call it with different parameter values to customize its behavior.</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../06-func/">Creating Functions</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>Define a function using <code class="highlighter-rouge">def name(...params...)</code>.</p>
</li>
        
        <li><p>The body of a function must be indented.</p>
</li>
        
        <li><p>Call a function using <code class="highlighter-rouge">name(...values...)</code>.</p>
</li>
        
        <li><p>Numbers are stored as integers or floating-point numbers.</p>
</li>
        
        <li><p>Integer division produces the whole part of the answer (not the fractional part).</p>
</li>
        
        <li><p>Each time a function is called, a new stack frame is created on the <strong>call stack</strong> to hold its parameters and local variables.</p>
</li>
        
        <li><p>Python looks for variables in the current stack frame before looking for them at the top level.</p>
</li>
        
        <li><p>Use <code class="highlighter-rouge">help(thing)</code> to view help for something.</p>
</li>
        
        <li><p>Put docstrings in functions to provide help for that function.</p>
</li>
        
        <li><p>Specify default values for parameters when defining a function using <code class="highlighter-rouge">name=value</code> in the parameter list.</p>
</li>
        
        <li><p>Parameters can be passed by matching based on name, by position, or by omitting them (in which case the default value is used).</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../07-errors/">Errors and Exceptions</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>Tracebacks can look intimidating, but they give us a lot of useful information about what went wrong in our program, including where the error occurred and what type of error it was.</p>
</li>
        
        <li><p>An error having to do with the ‘grammar’ or syntax of the program is called a <code class="highlighter-rouge">SyntaxError</code>. If the issue has to do with how the code is indented, then it will be called an <code class="highlighter-rouge">IndentationError</code>.</p>
</li>
        
        <li><p>A <code class="highlighter-rouge">NameError</code> will occur if you use a variable that has not been defined, either because you meant to use quotes around a string, you forgot to define the variable, or you just made a typo.</p>
</li>
        
        <li><p>Containers like lists and strings will generate errors if you try to access items in them that do not exist. This type of error is called an <code class="highlighter-rouge">IndexError</code>.</p>
</li>
        
        <li><p>Trying to read a file that does not exist will give you an <code class="highlighter-rouge">FileNotFoundError</code>. Trying to read a file that is open for writing, or writing to a file that is open for reading, will give you an <code class="highlighter-rouge">IOError</code>.</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../08-defensive/">Defensive Programming</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>Program defensively, i.e., assume that errors are going to arise, and write code to detect them when they do.</p>
</li>
        
        <li><p>Put assertions in programs to check their state as they run, and to help readers understand how those programs are supposed to work.</p>
</li>
        
        <li><p>Use preconditions to check that the inputs to a function are safe to use.</p>
</li>
        
        <li><p>Use postconditions to check that the output from a function is safe to use.</p>
</li>
        
        <li><p>Write tests before writing code in order to help determine exactly what that code is supposed to do.</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../09-debugging/">Debugging</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>Know what code is supposed to do <em>before</em> trying to debug it.</p>
</li>
        
        <li><p>Make it fail every time.</p>
</li>
        
        <li><p>Make it fail fast.</p>
</li>
        
        <li><p>Change one thing at a time, and for a reason.</p>
</li>
        
        <li><p>Keep track of what you’ve done.</p>
</li>
        
        <li><p>Be humble.</p>
</li>
        
        </ul>
      </td>
    </tr>
  

  
    <tr>
      <td class="col-md-3">
        <a href="../10-cmdline/">Command-Line Programs</a>
      </td>
      <td class="col-md-9">
        <ul>
        
        <li><p>The <code class="highlighter-rouge">sys</code> library connects a Python program to the system it is running on.</p>
</li>
        
        <li><p>The list <code class="highlighter-rouge">sys.argv</code> contains the command-line arguments that a program was run with.</p>
</li>
        
        <li><p>Avoid silent failures.</p>
</li>
        
        <li><p>The pseudo-file <code class="highlighter-rouge">sys.stdin</code> connects to a program’s standard input.</p>
</li>
        
        <li><p>The pseudo-file <code class="highlighter-rouge">sys.stdout</code> connects to a program’s standard output.</p>
</li>
        
        </ul>
      </td>
    </tr>
  

</table>

<h2 id="glossary">Glossary</h2>

<dl>
  <dt id="additive-color-model">additive color model</dt>
  <dd>A way to represent colors as the sum of contributions from primary colors
such as <a href="#rgb">red, green, and blue</a>.</dd>
  <dt id="argument">argument</dt>
  <dd>A value given to a function or program when it runs.
The term is often used interchangeably (and inconsistently) with <a href="#parameter">parameter</a>.</dd>
  <dt id="assertion">assertion</dt>
  <dd>An expression which is supposed to be true at a particular point in a program.
Programmers typically put assertions in their code to check for errors;
if the assertion fails (i.e., if the expression evaluates as false),
the program halts and produces an error message.
See also: <a href="#invariant">invariant</a>, <a href="#precondition">precondition</a>, <a href="#postcondition">postcondition</a>.</dd>
  <dt id="assign">assign</dt>
  <dd>To give a value a name by associating a variable with it.</dd>
  <dt id="body">body</dt>
  <dd>(of a function): the statements that are executed when a function runs.</dd>
  <dt id="call-stack">call stack</dt>
  <dd>A data structure inside a running program that keeps track of active function calls.</dd>
  <dt id="case-insensitive">case-insensitive</dt>
  <dd>Treating text as if upper and lower case characters of the same letter were the same.
See also: <a href="#case-sensitive">case-sensitive</a>.</dd>
  <dt id="case-sensitive">case-sensitive</dt>
  <dd>Treating text as if upper and lower case characters of the same letter are different.
See also: <a href="#case-insensitive">case-insensitive</a>.</dd>
  <dt id="comment">comment</dt>
  <dd>A remark in a program that is intended to help human readers understand what is going on,
but is ignored by the computer.
Comments in Python, R, and the Unix shell start with a <code class="highlighter-rouge">#</code> character and run to the end of the line;
comments in SQL start with <code class="highlighter-rouge">--</code>,
and other languages have other conventions.</dd>
  <dt id="compose">compose</dt>
  <dd>To apply one function to the result of another, such as <code class="highlighter-rouge">f(g(x))</code>.</dd>
  <dt id="conditional-statement">conditional statement</dt>
  <dd>A statement in a program that might or might not be executed
depending on whether a test is true or false.</dd>
  <dt id="comma-separated-values">comma-separated values</dt>
  <dd>(CSV) A common textual representation for tables
in which the values in each row are separated by commas.</dd>
  <dt id="default-value">default value</dt>
  <dd>A value to use for a <a href="#parameter">parameter</a> if nothing is specified explicitly.</dd>
  <dt id="defensive-programming">defensive programming</dt>
  <dd>The practice of writing programs that check their own operation to catch errors as early as possible.</dd>
  <dt id="delimiter">delimiter</dt>
  <dd>A character or characters used to separate individual values,
such as the commas between columns in a <a href="#comma-separated-values">CSV</a> file.</dd>
  <dt id="docstring">docstring</dt>
  <dd>Short for “documentation string”,
this refers to textual documentation embedded in Python programs.
Unlike comments, docstrings are preserved in the running program
and can be examined in interactive sessions.</dd>
  <dt id="documentation">documentation</dt>
  <dd>Human-language text written to explain what software does,
how it works, or how to use it.</dd>
  <dt id="dotted-notation">dotted notation</dt>
  <dd>A two-part notation used in many programming languages
in which <code class="highlighter-rouge">thing.component</code> refers to the <code class="highlighter-rouge">component</code> belonging to <code class="highlighter-rouge">thing</code>.</dd>
  <dt id="empty-string">empty string</dt>
  <dd>A character string containing no characters,
often thought of as the “zero” of text.</dd>
  <dt id="encapsulation">encapsulation</dt>
  <dd>The practice of hiding something’s implementation details
so that the rest of a program can worry about <em>what</em> it does
rather than <em>how</em> it does it.</dd>
  <dt id="floating-point-number">floating-point number</dt>
  <dd>A number containing a fractional part and an exponent.
See also: <a href="#integer">integer</a>.</dd>
  <dt id="for-loop">for loop</dt>
  <dd>A loop that is executed once for each value in some kind of set, list, or range.
See also: <a href="#while-loop">while loop</a>.</dd>
  <dt id="function">function</dt>
  <dd>A group of instructions (i.e., lines of code) that transform
some input <a href="#argument">arguments</a> to some output.</dd>
  <dt id="function-call">function call</dt>
  <dd>A use of a function in another piece of software.</dd>
  <dt id="immutable">immutable</dt>
  <dd>Unchangeable.
The value of immutable data cannot be altered after it has been created.
See also: <a href="#mutable">mutable</a>.</dd>
  <dt id="import">import</dt>
  <dd>To load a <a href="#library">library</a> into a program.</dd>
  <dt id="in-place-operators">in-place operators</dt>
  <dd>An operator such as <code class="highlighter-rouge">+=</code> that provides a shorthand notation for
the common case in which the variable being assigned to
is also an operand on the right hand side of the assignment.
For example, the statement <code class="highlighter-rouge">x += 3</code> means the same thing as <code class="highlighter-rouge">x = x + 3</code>.</dd>
  <dt id="index">index</dt>
  <dd>A subscript that specifies the location of a single value in a collection,
such as a single pixel in an image.</dd>
  <dt id="inner-loop">inner loop</dt>
  <dd>A loop that is inside another loop. See also: <a href="#outer-loop">outer loop</a>.</dd>
  <dt id="integer">integer</dt>
  <dd>A whole number, such as -12343. See also: <a href="#floating-point-number">floating-point number</a>.</dd>
  <dt id="invariant">invariant</dt>
  <dd>An expression whose value doesn’t change during the execution of a program,
typically used in an <a href="#assertion">assertion</a>.
See also: <a href="#precondition">precondition</a>, <a href="#postcondition">postcondition</a>.</dd>
  <dt id="library">library</dt>
  <dd>A family of code units (functions, classes, variables) that implement a set of
related tasks.</dd>
  <dt id="loop-variable">loop variable</dt>
  <dd>The variable that keeps track of the progress of the loop.</dd>
  <dt id="member">member</dt>
  <dd>A variable contained within an <a href="#object">object</a>.</dd>
  <dt id="method">method</dt>
  <dd>A function which is tied to a particular <a href="#object">object</a>.
Each of an object’s methods typically implements one of the things it can do,
or one of the questions it can answer.</dd>
  <dt id="object">object</dt>
  <dd>A collection of conceptually related variables (<a href="#member">members</a>) and
functions using those variables (<a href="#method">methods</a>).</dd>
  <dt id="outer-loop">outer loop</dt>
  <dd>A loop that contains another loop.
See also: <a href="#inner-loop">inner loop</a>.</dd>
  <dt id="parameter">parameter</dt>
  <dd>A variable named in the function’s declaration that is used to hold a value passed into the call.
The term is often used interchangeably (and inconsistently) with <a href="#argument">argument</a>.</dd>
  <dt id="pipe">pipe</dt>
  <dd>A connection from the output of one program to the input of another.
When two or more programs are connected in this way, they are called a “pipeline”.</dd>
  <dt id="postcondition">postcondition</dt>
  <dd>A condition that a function (or other block of code) guarantees is true
once it has finished running.
Postconditions are often represented using <a href="#assertion">assertions</a>.</dd>
  <dt id="precondition">precondition</dt>
  <dd>A condition that must be true in order for a function (or other block of code) to run correctly.</dd>
  <dt id="regression">regression</dt>
  <dd>To re-introduce a bug that was once fixed.</dd>
  <dt id="return-statement">return statement</dt>
  <dd>A statement that causes a function to stop executing and return a value to its caller immediately.</dd>
  <dt id="rgb">RGB</dt>
  <dd>An <a href="#additive-color-model">additive model</a>
that represents colors as combinations of red, green, and blue.
Each color’s value is typically in the range 0..255
(i.e., a one-byte integer).</dd>
  <dt id="sequence">sequence</dt>
  <dd>A collection of information that is presented in a specific order.
For example, in Python, a <a href="#string">string</a> is a sequence of characters,
while a list is a sequence of any variable.</dd>
  <dt id="shape">shape</dt>
  <dd>An array’s dimensions, represented as a vector.
For example, a 5×3 array’s shape is <code class="highlighter-rouge">(5,3)</code>.</dd>
  <dt id="silent-failure">silent failure</dt>
  <dd>Failing without producing any warning messages.
Silent failures are hard to detect and debug.</dd>
  <dt id="slice">slice</dt>
  <dd>A regular subsequence of a larger sequence,
such as the first five elements or every second element.</dd>
  <dt id="stack-frame">stack frame</dt>
  <dd>A data structure that provides storage for a function’s local variables.
Each time a function is called, a new stack frame is created
and put on the top of the <a href="#call-stack">call stack</a>. When the function returns,
the stack frame is discarded.</dd>
  <dt id="standard-input">standard input</dt>
  <dd>A process’s default input stream.
In interactive command-line applications,
it is typically connected to the keyboard; in a <a href="#pipe">pipe</a>,
it receives data from the <a href="#standard-output">standard output</a> of the preceding process.</dd>
  <dt id="standard-output">standard output</dt>
  <dd>A process’s default output stream.
In interactive command-line applications,
data sent to standard output is displayed on the screen;
in a <a href="#pipe">pipe</a>,
it is passed to the <a href="#standard-input">standard input</a> of the next process.</dd>
  <dt id="string">string</dt>
  <dd>Short for “character string”,
a <a href="#sequence">sequence</a> of zero or more characters.</dd>
  <dt id="syntax-error">syntax error</dt>
  <dd>A programming error that occurs when statements are in an order or contain characters
not expected by the programming language.</dd>
  <dt id="test-oracle">test oracle</dt>
  <dd>A program, device, data set, or human being
against which the results of a test can be compared.</dd>
  <dt id="test-driven-development">test-driven development</dt>
  <dd>The practice of writing unit tests <em>before</em> writing the code they test.</dd>
  <dt id="traceback">traceback</dt>
  <dd>The sequence of function calls that led to an error.</dd>
  <dt id="tuple">tuple</dt>
  <dd>An <a href="#immutable">immutable</a> <a href="#sequence">sequence</a> of values.</dd>
  <dt id="type">type</dt>
  <dd>The classification of something in a program (for example, the contents of a variable)
as a kind of number (e.g. <a href="#float">floating-point</a>, <a href="#integer">integer</a>), <a href="#string">string</a>, or something else.</dd>
  <dt id="type-of-error">type of error</dt>
  <dd>Indicates the nature of an error in a program. For example, in Python,
an <code class="highlighter-rouge">IOError</code> to problems with file input/output.
See also: <a href="#syntax-error">syntax error</a>.</dd>
  <dt id="while-loop">while loop</dt>
  <dd>A loop that keeps executing as long as some condition is true.
See also: <a href="#for-loop">for loop</a>.</dd>
</dl>



      
      
<footer>
  <div class="row">
    <div class="col-md-6" align="left">
      <h4>
	Copyright &copy; 2016–2017
	
	<a href="https://software-carpentry.org">Software Carpentry Foundation</a>
	
      </h4>
    </div>
    <div class="col-md-6" align="right">
      <h4>
	
	<a href="/edit/gh-pages/reference.md">Edit on GitHub</a>
	
	/
	<a href="/blob/gh-pages/CONTRIBUTING.md">Contributing</a>
	/
	<a href="/">Source</a>
	/
	<a href="/blob/gh-pages/CITATION">Cite</a>
	/
	<a href="">Contact</a>
      </h4>
    </div>
  </div>
</footer>

      
    </div>
    
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/lesson.js"></script>
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-37305346-2', 'auto');
  ga('send', 'pageview');
</script>

  </body>
</html>