267267 < a href ="../04-tables/none-print.html " class ="sidebar-item-text sidebar-link ">
268268 < span class ="menu-text "> None and Print</ span > </ a >
269269 </ div >
270+ </ li >
271+ </ ul >
272+ </ li >
273+ < li class ="sidebar-item sidebar-item-section ">
274+ < div class ="sidebar-item-container ">
275+ < a href ="../05-variables/index.html " class ="sidebar-item-text sidebar-link ">
276+ < span class ="menu-text "> L05: Variables in Social Science</ span > </ a >
277+ < a class ="sidebar-item-toggle text-start collapsed " data-bs-toggle ="collapse " data-bs-target ="#quarto-sidebar-section-5 " role ="navigation " aria-expanded ="false " aria-label ="Toggle section ">
278+ < i class ="bi bi-chevron-right ms-2 "> </ i >
279+ </ a >
280+ </ div >
281+ < ul id ="quarto-sidebar-section-5 " class ="collapse list-unstyled sidebar-section depth1 ">
282+ < li class ="sidebar-item ">
283+ < div class ="sidebar-item-container ">
284+ < a href ="../05-variables/index.html " class ="sidebar-item-text sidebar-link ">
285+ < span class ="menu-text "> Variables and Variable Types</ span > </ a >
286+ </ div >
287+ </ li >
288+ < li class ="sidebar-item ">
289+ < div class ="sidebar-item-container ">
290+ < a href ="../05-variables/units-of-analysis.html " class ="sidebar-item-text sidebar-link ">
291+ < span class ="menu-text "> Units of Analysis</ span > </ a >
292+ </ div >
293+ </ li >
294+ </ ul >
295+ </ li >
296+ < li class ="sidebar-item sidebar-item-section ">
297+ < div class ="sidebar-item-container ">
298+ < a href ="../06-variables-ii/index.html " class ="sidebar-item-text sidebar-link ">
299+ < span class ="menu-text "> L06: Causality vs. EDA</ span > </ a >
300+ < a class ="sidebar-item-toggle text-start collapsed " data-bs-toggle ="collapse " data-bs-target ="#quarto-sidebar-section-6 " role ="navigation " aria-expanded ="false " aria-label ="Toggle section ">
301+ < i class ="bi bi-chevron-right ms-2 "> </ i >
302+ </ a >
303+ </ div >
304+ < ul id ="quarto-sidebar-section-6 " class ="collapse list-unstyled sidebar-section depth1 ">
305+ < li class ="sidebar-item ">
306+ < div class ="sidebar-item-container ">
307+ < a href ="../06-variables-ii/index.html " class ="sidebar-item-text sidebar-link ">
308+ < span class ="menu-text "> Causality vs. EDA</ span > </ a >
309+ </ div >
310+ </ li >
311+ < li class ="sidebar-item ">
312+ < div class ="sidebar-item-container ">
313+ < a href ="../06-variables-ii/sample-population.html " class ="sidebar-item-text sidebar-link ">
314+ < span class ="menu-text "> Sample vs. Population</ span > </ a >
315+ </ div >
270316</ li >
271317 </ ul >
272318 </ li >
@@ -418,10 +464,10 @@ <h3 class="anchored" data-anchor-id="summary-of-numeric-operators">Summary of Nu
418464< td > < code > 7.5</ code > </ td >
419465</ tr >
420466< tr class ="odd ">
421- < td > Integer division</ td >
422- < td > Cuts off remainder</ td >
467+ < td > Integer division< br > (Cuts off remainder)</ td >
423468< td > < code > //</ code > </ td >
424469< td > < code > 15 // 2</ code > </ td >
470+ < td > < code > 7</ code > </ td >
425471</ tr >
426472< tr class ="even ">
427473< td > Remainder/Modulo</ td >
@@ -470,19 +516,19 @@ <h2 class="anchored" data-anchor-id="names-and-call-expressions">Names and Call
470516</ div >
471517</ div >
472518< p > One analogy for names is suitcase tags. Consider the following assignment statement:</ p >
473- < div id ="90dc3c8f " class ="cell " data-execution_count ="1 ">
519+ < div id ="66863114 " class ="cell " data-execution_count ="1 ">
474520< div class ="sourceCode cell-code " id ="cb1 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb1-1 "> < a href ="#cb1-1 " aria-hidden ="true " tabindex ="-1 "> </ a > x < span class ="op "> =</ span > < span class ="dv "> 3</ span > </ span > </ code > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ pre > </ div >
475521</ div >
476522< p > This statement assigns the name < code > x</ code > to the value < code > 3</ code > . Like a suitcase tag, the name < code > x</ code > is bound to the value < code > 3</ code > .</ p >
477- < div id ="33d312a8 " class ="cell " data-execution_count ="2 ">
523+ < div id ="874ef3ad " class ="cell " data-execution_count ="2 ">
478524< div class ="sourceCode cell-code " id ="cb2 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb2-1 "> < a href ="#cb2-1 " aria-hidden ="true " tabindex ="-1 "> </ a > x</ span > </ code > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ pre > </ div >
479525< div class ="cell-output cell-output-display " data-execution_count ="2 ">
480526< pre > < code > 3</ code > </ pre >
481527</ div >
482528</ div >
483529< p > Python first evaluates the expression on the right-hand side of the < code > =</ code > assignment operator, then binds the name < code > x</ code > to the resulting value.</ p >
484530< p > The below statement re-assigns the name < code > x</ code > . Think of this as moving the suitcase tag to a different suitcase.</ p >
485- < div id ="497e4618 " class ="cell " data-execution_count ="3 ">
531+ < div id ="30997e15 " class ="cell " data-execution_count ="3 ">
486532< div class ="sourceCode cell-code " id ="cb4 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb4-1 "> < a href ="#cb4-1 " aria-hidden ="true " tabindex ="-1 "> </ a > x < span class ="op "> =</ span > < span class ="dv "> 1</ span > < span class ="op "> +</ span > < span class ="dv "> 2</ span > < span class ="op "> *</ span > < span class ="dv "> 3</ span > < span class ="op "> -</ span > < span class ="dv "> 4</ span > < span class ="op "> //</ span > < span class ="dv "> 5</ span > </ span >
487533< span id ="cb4-2 "> < a href ="#cb4-2 " aria-hidden ="true " tabindex ="-1 "> </ a > x</ span > </ code > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ pre > </ div >
488534< div class ="cell-output cell-output-display " data-execution_count ="3 ">
@@ -507,7 +553,7 @@ <h3 class="anchored" data-anchor-id="a-note-on-function-calls">A note on functio
507553</ div >
508554</ div >
509555< p > Consider the below Python code:</ p >
510- < div id ="f23d7077 " class ="cell " data-execution_count ="4 ">
556+ < div id ="9da9ce8e " class ="cell " data-execution_count ="4 ">
511557< div class ="sourceCode cell-code " id ="cb6 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb6-1 "> < a href ="#cb6-1 " aria-hidden ="true " tabindex ="-1 "> </ a > x < span class ="op "> =</ span > < span class ="dv "> 4</ span > </ span >
512558< span id ="cb6-2 "> < a href ="#cb6-2 " aria-hidden ="true " tabindex ="-1 "> </ a > y < span class ="op "> =</ span > < span class ="bu "> max</ span > (< span class ="op "> -</ span > < span class ="dv "> 2</ span > , < span class ="dv "> 9</ span > ) < span class ="op "> +</ span > x</ span > </ code > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ pre > </ div >
513559</ div >
@@ -523,7 +569,7 @@ <h3 class="anchored" data-anchor-id="programming-style-and-comments">Programming
523569< p > Good style practices can involve comments, meaningful names, whitespace, markdown cells interspersed with code cells, etc. < a href ="https://inferentialthinking.com/chapters/03/2/Names.html "> Ch 3.2</ a > of < em > Inferential Thinking</ em > describes meaningful names; we discuss comments below.</ p >
524570< p > < strong > Comments</ strong > are used to explain what code does. Good programmers write code that is self-evident and use comments only where necessary.</ p >
525571< p > In Python, you can write comments in the same line as code (“in-line” comments) using < code > #</ code > :</ p >
526- < div id ="02de9810 " class ="cell " data-execution_count ="5 ">
572+ < div id ="6122c9a4 " class ="cell " data-execution_count ="5 ">
527573< div class ="sourceCode cell-code " id ="cb7 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb7-1 "> < a href ="#cb7-1 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="dv "> 3</ span > < span class ="op "> +</ span > < span class ="dv "> 4</ span > < span class ="co "> # simple arithmetic</ span > </ span > </ code > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ pre > </ div >
528574< div class ="cell-output cell-output-display " data-execution_count ="5 ">
529575< pre > < code > 7</ code > </ pre >
@@ -548,7 +594,7 @@ <h3 class="anchored" data-anchor-id="debugging">Debugging</h3>
548594< h3 class ="anchored " data-anchor-id ="practice-with-errors "> Practice with Errors</ h3 >
549595< p > Try these on for size:</ p >
550596< p > < strong > Syntax errors</ strong > are errors in writing “valid” Python that cannot even create nonsensical Python code.</ p >
551- < div id ="5feb0c8e " class ="cell " data-execution_count ="6 ">
597+ < div id ="c23dbff7 " class ="cell " data-execution_count ="6 ">
552598< div class ="sourceCode cell-code " id ="cb9 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb9-1 "> < a href ="#cb9-1 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="dv "> 3</ span > < span class ="op "> **</ span > < span class ="op "> /</ span > < span class ="dv "> 4</ span > </ span > </ code > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ pre > </ div >
553599< div class ="cell-output cell-output-error ">
554600< div class ="ansi-escaped-output ">
@@ -561,14 +607,14 @@ <h3 class="anchored" data-anchor-id="practice-with-errors">Practice with Errors<
561607</ div >
562608</ div >
563609< p > Why might the below code < em > not</ em > error? (Hint: What does < code > -</ code > represent?)</ p >
564- < div id ="9f78e48c " class ="cell " data-execution_count ="7 ">
610+ < div id ="6d2aa667 " class ="cell " data-execution_count ="7 ">
565611< div class ="sourceCode cell-code " id ="cb10 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb10-1 "> < a href ="#cb10-1 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="dv "> 9</ span > < span class ="op "> **</ span > < span class ="op "> -</ span > < span class ="fl "> .5</ span > </ span > </ code > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ pre > </ div >
566612< div class ="cell-output cell-output-display " data-execution_count ="7 ">
567613< pre > < code > 0.3333333333333333</ code > </ pre >
568614</ div >
569615</ div >
570616< p > Once you fix syntax errors, you may still encounter < strong > functionality errors</ strong > , which can be errors caused during execution that leads to your program crashing. Here’s one common one:</ p >
571- < div id ="81070f2c " class ="cell " data-execution_count ="8 ">
617+ < div id ="566d4a9f " class ="cell " data-execution_count ="8 ">
572618< div class ="sourceCode cell-code " id ="cb12 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb12-1 "> < a href ="#cb12-1 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="dv "> 5</ span > < span class ="op "> /</ span > < span class ="dv "> 0</ span > </ span > </ code > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ pre > </ div >
573619< div class ="cell-output cell-output-error ">
574620< div class ="ansi-escaped-output ">
0 commit comments