{"id":47362,"date":"2026-11-24T22:04:45","date_gmt":"2026-11-24T22:04:45","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=47362"},"modified":"2026-11-24T22:04:45","modified_gmt":"2026-11-24T22:04:45","slug":"jupyter-notebook-lab-session-6-conditions-control-flow-looping","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/jupyter-notebook-lab-session-6-conditions-control-flow-looping\/","title":{"rendered":"Jupyter notebook \u2013 Lab Session \u2013 6 \u2013 Conditions, Control Flow &amp; Looping"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This lab works through Python decision-making and looping in a Jupyter notebook: <code>if<\/code>, <code>elif<\/code> and <code>else<\/code>, one-line conditionals, the conditional (ternary) expression, <code>pass<\/code>, <code>while<\/code> and <code>for<\/code> loops, <code>break<\/code>, <code>continue<\/code> and the loop <code>else<\/code> clause. Below the notebook you&#039;ll find an explanation of each concept, corrections to a few cells that give misleading output or fail, idiomatic alternatives and practice exercises.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/0a705ebfab26cda90b4d24e19198dd4d.js\"><\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">What the notebook demonstrates<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The notebook above is a run of small cells, and each one isolates a single rule of Python control flow. The table maps each topic to the point it teaches. Use it to check your understanding once you&#039;ve run the cells.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Topic<\/th><th>Key point<\/th><\/tr><\/thead><tbody><tr><td><code>if<\/code> with <code>x<\/code>, <code>y<\/code>, <code>in<\/code><\/td><td>Any value can be a condition. <code>0<\/code>, empty strings, empty lists and <code>None<\/code> are falsy. Most other values are truthy.<\/td><\/tr><tr><td>Indentation and blocks<\/td><td>Python has no braces. A block (suite) is the set of lines indented under a colon. The block ends when the indentation goes back.<\/td><\/tr><tr><td><code>else<\/code> \/ <code>elif<\/code><\/td><td>Python checks branches from top to bottom and runs only the first true one. <code>else<\/code> catches everything else.<\/td><\/tr><tr><td><code>elif 1\/0<\/code> cell<\/td><td>After one branch matches, Python skips the remaining conditions, so <code>1\/0<\/code> and the undefined <code>var<\/code> never run.<\/td><\/tr><tr><td>One-line <code>if<\/code><\/td><td><code>if cond: a; b; c<\/code> is legal, but it hurts readability. Use it sparingly.<\/td><\/tr><tr><td>Conditional expression<\/td><td><code>value_if_true if condition else value_if_false<\/code> returns a value, so you can use it inside <code>print()<\/code> or an assignment.<\/td><\/tr><tr><td><code>pass<\/code><\/td><td>A no-op placeholder for places where Python&#039;s syntax requires a statement.<\/td><\/tr><tr><td><code>while<\/code><\/td><td>Repeats while the condition is true. Something inside the loop must eventually make it false.<\/td><\/tr><tr><td><code>for<\/code><\/td><td>Iterates over any iterable: lists, tuples, strings, dictionaries (keys by default) and <code>range()<\/code>.<\/td><\/tr><tr><td><code>break<\/code> \/ <code>continue<\/code><\/td><td><code>break<\/code> exits the loop. <code>continue<\/code> skips to the next iteration.<\/td><\/tr><tr><td>Loop <code>else<\/code><\/td><td>Runs only when the loop finishes without hitting <code>break<\/code>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Running the notebook cleanly<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Download the <code>.ipynb<\/code> file from the gist (use the <strong>Download ZIP<\/strong> or <strong>Raw<\/strong> button) and put it in a working folder.<\/li>\n\n\n<li>Start Jupyter from that folder with <code>jupyter lab<\/code> or <code>jupyter notebook<\/code>.<\/li>\n\n\n<li>Before you run anything, comment out the <code>while True:<\/code> cell, or be ready to interrupt it (see the warning below).<\/li>\n\n\n<li>Select <strong>Kernel &gt; Restart Kernel and Run All Cells<\/strong>. The saved execution counts jump around (for example 36, then 2, then 1), which shows the original was not run top to bottom in a single session.<\/li>\n\n\n<li>When a cell asks for input, as the temperature converter does, type something like <code>45F<\/code> in the box that appears and press Enter.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> <strong>Infinite loop warning:<\/strong> <code>while True: print(&#039;foo&#039;)<\/code> never ends and floods the output area. To stop it, press <code>I<\/code> twice in command mode, click the stop button or choose <strong>Kernel &gt; Interrupt Kernel<\/strong>. If the browser tab stops responding, restart the kernel.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Corrections to the example notebook<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Stale output in the ternary cell.<\/strong> The first <code>raining<\/code> cell sets <code>raining = False<\/code> but shows <code>Let&#039;s go to the library<\/code>. The cell was edited after it last ran. Running it again prints <code>beach<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">raining = <span class=\"hljs-keyword\">False<\/span>\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">\"Let's go to the\"<\/span>, <span class=\"hljs-string\">'beach'<\/span> <span class=\"hljs-keyword\">if<\/span> not raining <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-string\">'library'<\/span>)\n<span class=\"hljs-comment\"># Output: Let's go to the beach<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Pseudocode cell.<\/strong> The cell containing <code>while &lt;expr&gt;:<\/code> is a syntax template, not code, so it always raises <code>SyntaxError<\/code>. Read it as documentation. Changing it to a markdown cell stops it from breaking <strong>Run All<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Mislabelled heading.<\/strong> The first cell under &quot;Nested while loops&quot; is a nested <code>if<\/code> statement. The nested <code>while<\/code> example is the second cell, which uses <code>a.pop(0)<\/code> and <code>b.pop(0)<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Book purchase boundary.<\/strong> The Indonesian variables mean book price (<code>hargaBuku<\/code>), magazine price (<code>hargaMajalah<\/code>) and money (<code>uang<\/code>). The outputs mean &quot;Buy book&quot;, &quot;Buy magazine&quot; and &quot;Not enough money&quot;. Because the code tests <code>uang &gt; hargaBuku<\/code>, someone holding exactly 20000 is told they can&#039;t afford a 20000 book. Use <code>&gt;=<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">book_price = <span class=\"hljs-number\">20000<\/span>\nmagazine_price = <span class=\"hljs-number\">5000<\/span>\nmoney = <span class=\"hljs-number\">20000<\/span>\n\n<span class=\"hljs-keyword\">if<\/span> money &gt;= book_price:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'Buy book'<\/span>)\nelif money &gt;= magazine_price:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'Buy magazine'<\/span>)\n<span class=\"hljs-keyword\">else<\/span>:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'Not enough money'<\/span>)\n<span class=\"hljs-comment\"># Output: Buy book<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Temperature converter crash.<\/strong> For input that doesn&#039;t end in <code>C<\/code> or <code>F<\/code>, the last cell prints an error message, then hits <code>print(..., result, ...)<\/code> where <code>result<\/code> was never assigned, and raises <code>NameError<\/code>. It also crashes with <code>ValueError<\/code> on decimals like <code>98.6F<\/code> or text like <code>abcF<\/code>, rejects lowercase units, and doesn&#039;t say which unit the result is in. A corrected version:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">temp = input(<span class=\"hljs-string\">'Enter a temperature to convert, e.g. 45F or 120C: '<\/span>).strip().upper()\n\n<span class=\"hljs-keyword\">try<\/span>:\n    degree = float(temp&#91;:<span class=\"hljs-number\">-1<\/span>])\nexcept ValueError:\n    degree = None\nunit = temp&#91;<span class=\"hljs-number\">-1<\/span>:]\n\n<span class=\"hljs-keyword\">if<\/span> degree is None:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'Enter a number followed by C or F.'<\/span>)\nelif unit == <span class=\"hljs-string\">'C'<\/span>:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'The temperature is'<\/span>, round(<span class=\"hljs-number\">9<\/span> * degree \/ <span class=\"hljs-number\">5<\/span> + <span class=\"hljs-number\">32<\/span>), <span class=\"hljs-string\">'degrees F'<\/span>)\nelif unit == <span class=\"hljs-string\">'F'<\/span>:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'The temperature is'<\/span>, round((degree - <span class=\"hljs-number\">32<\/span>) * <span class=\"hljs-number\">5<\/span> \/ <span class=\"hljs-number\">9<\/span>), <span class=\"hljs-string\">'degrees C'<\/span>)\n<span class=\"hljs-keyword\">else<\/span>:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'Enter a number followed by C or F.'<\/span>)\n\n<span class=\"hljs-comment\"># Input 45F   -&gt; The temperature is 7 degrees C<\/span>\n<span class=\"hljs-comment\"># Input 100c  -&gt; The temperature is 212 degrees F<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Each branch now prints its own result, so no path reaches a variable that was never assigned. <code>.strip().upper()<\/code> handles stray spaces and lowercase units. <code>try\/except<\/code> handles input that isn&#039;t a number.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Loop else, break and continue in practice<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The loop <code>else<\/code> clause confuses most newcomers. Read it as &quot;no break&quot;. Its main use is searching: <code>break<\/code> when you find the item, and the <code>else<\/code> branch handles the case where nothing matched. You don&#039;t need a separate flag variable.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">numbers = &#91;<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">7<\/span>, <span class=\"hljs-number\">11<\/span>, <span class=\"hljs-number\">15<\/span>]\n\n<span class=\"hljs-keyword\">for<\/span> n in numbers:\n    <span class=\"hljs-keyword\">if<\/span> n % <span class=\"hljs-number\">2<\/span> == <span class=\"hljs-number\">0<\/span>:\n        <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'First even number:'<\/span>, n)\n        <span class=\"hljs-keyword\">break<\/span>\n<span class=\"hljs-keyword\">else<\/span>:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'No even number found'<\/span>)\n\n<span class=\"hljs-comment\"># Output: No even number found<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Change the list to <code>[3, 8, 11]<\/code> and the output becomes <code>First even number: 8<\/code>. The <code>else<\/code> branch is skipped because the loop ended with <code>break<\/code>. In nested loops, <code>break<\/code> and <code>continue<\/code> only affect the innermost loop they appear in.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">More idiomatic ways to write the same logic<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The notebook sticks to basic forms. Real-world Python code tends to use these patterns instead:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Chained comparison instead of: age &gt;= 18 and age &lt; 65<\/span>\nage = <span class=\"hljs-number\">30<\/span>\n<span class=\"hljs-keyword\">if<\/span> <span class=\"hljs-number\">18<\/span> &lt;= age &lt; <span class=\"hljs-number\">65<\/span>:\n    <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'adult'<\/span>)\n\n<span class=\"hljs-comment\"># Truthiness instead of: while len(a):<\/span>\na = &#91;<span class=\"hljs-string\">'foo'<\/span>, <span class=\"hljs-string\">'bar'<\/span>]\n<span class=\"hljs-keyword\">while<\/span> a:\n    <span class=\"hljs-keyword\">print<\/span>(a.pop(<span class=\"hljs-number\">0<\/span>))\n\n<span class=\"hljs-comment\"># Index and value together<\/span>\n<span class=\"hljs-keyword\">for<\/span> i, fruit in enumerate(&#91;<span class=\"hljs-string\">'apple'<\/span>, <span class=\"hljs-string\">'banana'<\/span>], start=<span class=\"hljs-number\">1<\/span>):\n    <span class=\"hljs-keyword\">print<\/span>(i, fruit)          <span class=\"hljs-comment\"># 1 apple \/ 2 banana<\/span>\n\n<span class=\"hljs-comment\"># Two sequences in parallel<\/span>\n<span class=\"hljs-keyword\">for<\/span> name, score in zip(&#91;<span class=\"hljs-string\">'Ana'<\/span>, <span class=\"hljs-string\">'Raj'<\/span>], &#91;<span class=\"hljs-number\">91<\/span>, <span class=\"hljs-number\">78<\/span>]):\n    <span class=\"hljs-keyword\">print<\/span>(name, score)\n\n<span class=\"hljs-comment\"># range(start, stop, step): stop is excluded<\/span>\n<span class=\"hljs-keyword\">for<\/span> n in range(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>, <span class=\"hljs-number\">-2<\/span>):\n    <span class=\"hljs-keyword\">print<\/span>(n)                 <span class=\"hljs-comment\"># 10 8 6 4 2<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">From Python 3.10, a <code>match<\/code> statement can replace a long <code>elif<\/code> chain like the <code>name == &#039;Fred&#039;<\/code> example. The notebook&#039;s kernel metadata shows Python 3.8, which doesn&#039;t support <code>match<\/code>. Check your version with <code>import sys; print(sys.version)<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">name = <span class=\"hljs-string\">'Adrian'<\/span>\nmatch name:\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'Fred'<\/span> | <span class=\"hljs-string\">'Xander'<\/span> | <span class=\"hljs-string\">'Adrian'<\/span> | <span class=\"hljs-string\">'Arnold'<\/span>:\n        <span class=\"hljs-keyword\">print<\/span>(f<span class=\"hljs-string\">'Hello {name}'<\/span>)\n    <span class=\"hljs-keyword\">case<\/span> _:\n        <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'Who are you?'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Common errors and how to fix them<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error or symptom<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>IndentationError: expected an indented block<\/code><\/td><td>A line ending in <code>:<\/code> has nothing indented under it<\/td><td>Indent the body, or use <code>pass<\/code> as a placeholder<\/td><\/tr><tr><td><code>SyntaxError: invalid syntax<\/code> on <code>if x = 5:<\/code><\/td><td><code>=<\/code> assigns a value. Comparisons use <code>==<\/code><\/td><td>Write <code>if x == 5:<\/code><\/td><\/tr><tr><td><code>NameError: name &#039;result&#039; is not defined<\/code><\/td><td>The variable is only assigned in some branches<\/td><td>Assign a default before the <code>if<\/code>, or print inside each branch<\/td><\/tr><tr><td>Cell shows <code>[*]<\/code> forever<\/td><td>Infinite <code>while<\/code> loop<\/td><td>Interrupt the kernel, then make sure the loop variable changes on every iteration<\/td><\/tr><tr><td>Items skipped while removing from a list in a <code>for<\/code> loop<\/td><td>The list changes size while you iterate over it<\/td><td>Loop over a copy (<code>for x in items[:]<\/code>) or build a new list<\/td><\/tr><tr><td><code>RuntimeError: dictionary changed size during iteration<\/code><\/td><td>Adding or removing keys while looping over a dict<\/td><td>Loop over <code>list(d)<\/code> or <code>list(d.items())<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Practice exercises<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Write a FizzBuzz for 1 to 30 using <code>for<\/code> and <code>range()<\/code>: print <code>Fizz<\/code> for multiples of 3, <code>Buzz<\/code> for multiples of 5, <code>FizzBuzz<\/code> for multiples of both, and the number otherwise.<\/li>\n\n\n<li>Use a <code>while<\/code> loop to keep asking for input until the user types <code>quit<\/code>, and print each entry in upper case.<\/li>\n\n\n<li>Given <code>scores = {&#039;Ana&#039;: 91, &#039;Raj&#039;: 78, &#039;Li&#039;: 64}<\/code>, use <code>d.items()<\/code> and an <code>if\/elif\/else<\/code> chain to print a grade (A for 90 or above, B for 75 or above, C for anything lower) for each student.<\/li>\n\n\n<li>Use <code>for ... else<\/code> to check whether a number entered by the user is prime, printing <code>prime<\/code> from the <code>else<\/code> branch.<\/li>\n\n\n<li>Rewrite the nested <code>son\/father\/grandfather<\/code> example so it uses chained comparisons and a conditional expression for gender.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between break and continue in Python?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>break<\/code> exits the innermost loop at once. <code>continue<\/code> skips the rest of the current iteration and moves on to the next one.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When does the else block of a Python loop run?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It runs when a <code>for<\/code> loop runs out of items, or when a <code>while<\/code> condition becomes false. It is skipped if the loop ends with <code>break<\/code>, and that&#039;s why it&#039;s useful for search loops.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does Python have a ternary operator?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. It&#039;s called a conditional expression and is written <code>a if condition else b<\/code>. For example, <code>s = &#039;teen&#039; if age &lt; 21 else &#039;adult&#039;<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I stop an infinite loop in Jupyter Notebook?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Interrupt the kernel: press <code>I<\/code> twice in command mode, click the stop button or use <strong>Kernel &gt; Interrupt Kernel<\/strong>. If that doesn&#039;t work, restart the kernel.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does Python have a switch statement?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Python 3.10 and later have <code>match<\/code>\/<code>case<\/code>, which covers switch-style logic and more. In older versions, use an <code>if\/elif\/else<\/code> chain or a dictionary lookup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/data-engineering-analytics\/data-science\/\">More Data Science tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/top-10-data-science-platforms-features-pros-cons-comparison\/\">Top 10 Data Science Platforms: Features, Pros, Cons &amp; Comparison<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/associate-data-scientist-role-blueprint-responsibilities-skills-kpis-and-career-path\/\">Associate Data Scientist: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This lab works through Python decision-making and looping in a Jupyter notebook: if, elif and else, one-line conditionals, the conditional (ternary) expression, pass, while and for loops,&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[6513],"tags":[15094],"class_list":["post-47362","post","type-post","status-publish","format-standard","hentry","category-data-science","tag-jupyter-notebook"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=47362"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47362\/revisions"}],"predecessor-version":[{"id":80193,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47362\/revisions\/80193"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=47362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=47362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=47362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}