<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Okall Omondi</title>
    <description>The latest articles on DEV Community by Okall Omondi (@okall_omondi).</description>
    <link>https://dev.to/okall_omondi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2736615%2F6a25e559-b43b-4972-b2ac-c3b7406ef384.png</url>
      <title>DEV Community: Okall Omondi</title>
      <link>https://dev.to/okall_omondi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/okall_omondi"/>
    <language>en</language>
    <item>
      <title>How Python Loops Actually Work: A Hands-On Guide with Real Projects</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Fri, 18 Sep 2026 06:04:31 +0000</pubDate>
      <link>https://dev.to/okall_omondi/how-python-loops-actually-work-a-hands-on-guide-with-real-projects-5blc</link>
      <guid>https://dev.to/okall_omondi/how-python-loops-actually-work-a-hands-on-guide-with-real-projects-5blc</guid>
      <description>&lt;p&gt;Like I said in my &lt;a href="https://dev.to/okall_omondi/how-python-operators-and-conditionals-actually-work-with-real-project-code-45og"&gt;Python Operators and Conditionals&lt;/a&gt; article, loops are also fundamental and understanding and using them in your program elevates your code to &lt;a href="https://www.google.com/search?q=thanos&amp;amp;sca_esv=8886e09268ba5536&amp;amp;sxsrf=APpeQnsQPO9OUSrCufsoWF2ocNIFhVSP2Q%3A1789709690502&amp;amp;ei=es2sau-DHoqxhbIP4tWLyAM&amp;amp;biw=2048&amp;amp;bih=926&amp;amp;gs_ssp=eJzj4tTP1TcwNo5PyzZg9GIryUjMyy8GADQeBbM&amp;amp;oq=thanos&amp;amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiBnRoYW5vcyoOCAAYkQIYsQMYgAQYigUyDhAuGJECGLEDGIAEGIoFMgsQABiABBiKBRiRAjIKEAAYgAQYigUYQzILEAAYgAQYigUYkQIyCxAAGIAEGIoFGJECMgoQLhiABBiKBRhDMgoQABiABBiKBRhDMgoQABiABBiKBRhDMgoQABiABBiKBRhDMgoQABiABBiKBRhDMh0QLhiRAhixAxiABBiKBRiXBRjcBBjeBBjgBNgBAUimXVCLOlivS3ACeAGQAQCYAbgCoAHJDqoBBTItNi4xuAEByAEA-AEBmAIKoAKxIsICChAAGEcY1gQYsAPCAg4QABjkAhjWBBiwA9gBAcICFxAuGNwGGLgGGNoGGNgCGMgDGLAD2AEBwgIEECMYJ8ICDRAjGKIHGJ4GGPAFGCfCAgsQLhiRAhiABBiKBcICCxAuGIAEGIoFGJECwgIKEC4YQxiABBiKBcICDRAjGPAFGJ4GGKIHGCfCAg0QLhhDGLEDGIAEGIoFwgIcEC4YQxixAxiABBiKBRiXBRjcBBjeBBjgBNgBAcICDRAAGIAEGIoFGEMYsQPCAg0QLhiABBiKBRhDGLEDwgIZEC4YQxiABBiKBRiXBRjcBBjeBBjgBNgBAZgDAIgGAZAGD7oGBggBEAEYCZIHCzIuMC41LjIuOC0xoAfocrIHBTItNS4yuAeOEMIHBTMtMy43yAfwAYAIAQ&amp;amp;sclient=gws-wiz-serp" rel="noopener noreferrer"&gt;Thanos&lt;/a&gt; status with his Infinity Stone.&lt;/p&gt;

&lt;p&gt;At first, loops felt like a bit of a party trick. I knew I needed them whenever I wanted to repeat something, but my code often turned into messy trial and error. I would mix up when to use &lt;code&gt;for&lt;/code&gt; instead of &lt;code&gt;while&lt;/code&gt;, trigger infinite loops that froze my terminal, or manually track counter variables when Python already had a cleaner way built in.&lt;/p&gt;

&lt;p&gt;Things clicked once I stopped treating loops as abstract syntax and started looking at them through practical problems.&lt;/p&gt;

&lt;p&gt;In this guide, I will walk you through how Python loops work, the difference between &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt;, how control keywords like &lt;code&gt;break&lt;/code&gt; and &lt;code&gt;continue&lt;/code&gt; alter execution, and why &lt;code&gt;enumerate()&lt;/code&gt; is a cleaner alternative to manual counters. To make this practical, I'll share real snippets from small projects I built while wrapping my head around these concepts.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Two Core Loops in Python
&lt;/h2&gt;

&lt;p&gt;Python gives us two primary tools for repetition: &lt;code&gt;for&lt;/code&gt; loops and &lt;code&gt;while&lt;/code&gt; loops. The distinction comes down to one question: &lt;strong&gt;Do you know how many times you need to run, or are you waiting for a condition to change?&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The &lt;code&gt;for&lt;/code&gt; Loop: Definite Iteration
&lt;/h3&gt;

&lt;p&gt;A &lt;code&gt;for&lt;/code&gt; loop moves through an iterable: like a list, a string, a tuple, or a range of numbers, one item at a time. It executes the code block for each element and stops automatically when it reaches the end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Alice&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bob&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Charlie&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, Python handles the bookkeeping. It grabs &lt;code&gt;"Alice"&lt;/code&gt;, runs the block, grabs &lt;code&gt;"Bob"&lt;/code&gt;, and finishes after &lt;code&gt;"Charlie"&lt;/code&gt;. You don't have to check list lengths or manage indices manually.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The &lt;code&gt;while&lt;/code&gt; Loop: Indefinite Iteration
&lt;/h3&gt;

&lt;p&gt;A &lt;code&gt;while&lt;/code&gt; loop runs as long as a specified condition evaluates to &lt;code&gt;True&lt;/code&gt;. Because you often do not know in advance how many iterations you will need, it works well for event loops, game loops, or user input validation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;attempts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;attempts&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You have &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; attempts left.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;attempts&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the condition never becomes &lt;code&gt;False&lt;/code&gt;, the loop runs forever. That is why every &lt;code&gt;while&lt;/code&gt; loop needs either state changes within its body or an explicit exit strategy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steering Loop Execution: &lt;code&gt;break&lt;/code&gt; and &lt;code&gt;continue&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Loops normally run on autopilot, but real-world logic often demands overrides. Python provides two primary keywords to alter loop flow: &lt;code&gt;break&lt;/code&gt; and &lt;code&gt;continue&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;break&lt;/code&gt;&lt;/strong&gt;: Immediately halts the loop and jumps straight to the code outside it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;continue&lt;/code&gt;&lt;/strong&gt;: Skips the rest of the current iteration and jumps directly to the next cycle.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s look at how both work in practice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project 1: User Validation Using a &lt;code&gt;while&lt;/code&gt; Loop and &lt;code&gt;break&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A classic scenario for a &lt;code&gt;while&lt;/code&gt; loop is taking input from a user. You cannot predict whether someone will provide a valid password on their first attempt or their tenth.&lt;/p&gt;

&lt;p&gt;I built a mini password checker that runs continuously using &lt;code&gt;while True&lt;/code&gt;, evaluates input rules, and calls &lt;code&gt;break&lt;/code&gt; as soon as the criteria are met:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_password&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter password: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;length_ok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;
        &lt;span class="n"&gt;not_password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;password&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="n"&gt;with_digit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isnumeric&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;char&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;length_ok&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;not_password&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;with_digit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Password accepted.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Password rejected. Try again.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;length_ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Password must be at least 8 characters long.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;not_password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Password cannot be &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;password&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;with_digit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Password must contain at least 1 digit.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;check_password&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why this works
&lt;/h3&gt;

&lt;p&gt;Setting &lt;code&gt;while True&lt;/code&gt; creates an intentional infinite loop. The program repeatedly prompts the user until every boolean condition evaluates to &lt;code&gt;True&lt;/code&gt;. Once the input satisfies &lt;code&gt;length_ok&lt;/code&gt;, &lt;code&gt;not_password&lt;/code&gt;, and &lt;code&gt;with_digit&lt;/code&gt;, the &lt;code&gt;break&lt;/code&gt; statement fires. That immediately terminates the loop without needing an external flag variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project 2: Data Filtering Using a &lt;code&gt;for&lt;/code&gt; Loop and &lt;code&gt;continue&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;While &lt;code&gt;break&lt;/code&gt; bails out entirely, &lt;code&gt;continue&lt;/code&gt; acts like a skip button. It is particularly useful when processing records where certain items should be ignored without stopping the whole workflow.&lt;/p&gt;

&lt;p&gt;Here is a transaction ledger script where I needed to calculate total net deposits and withdrawals while filtering out administrative service fees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;transactions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Deposit&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Withdrawal&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Deposit&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Fee&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Deposit&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;transaction_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;transactions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;transaction_type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Fee&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;  &lt;span class="c1"&gt;# Skip this iteration entirely
&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;transaction_type&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The total transacted: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why &lt;code&gt;continue&lt;/code&gt; is useful here
&lt;/h3&gt;

&lt;p&gt;When the loop encounters &lt;code&gt;('Fee', -50)&lt;/code&gt;, the condition triggers &lt;code&gt;continue&lt;/code&gt;. Python skips both &lt;code&gt;total += amount&lt;/code&gt; and the &lt;code&gt;print()&lt;/code&gt; statement below it, jumping immediately to the next tuple &lt;code&gt;('Deposit', 2000)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Without &lt;code&gt;continue&lt;/code&gt;, you would need to wrap the calculation in nested &lt;code&gt;if/else&lt;/code&gt; blocks. Using &lt;code&gt;continue&lt;/code&gt; keeps your primary business logic unindented and easier to read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project 3: Clean Tracking with &lt;code&gt;enumerate()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A common beginner habit when needing item positions is manually tracking an index counter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# The cluttered way
&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Apples&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bananas&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Cherries&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or worse, looping over &lt;code&gt;range(len(items))&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# The clunky way
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python provides &lt;code&gt;enumerate()&lt;/code&gt; to solve this cleanly. It wraps any iterable and yields pairs containing the current count along with the item itself.&lt;/p&gt;

&lt;p&gt;Here is a mini task checklist script demonstrating how clean this looks in a project context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Review pull requests&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Fix database migration bug&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Update API documentation&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Send release notes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Today&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s Priority Queue:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;priority&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;priority&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;] &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Today's Priority Queue:
[1] Review pull requests
[2] Fix database migration bug
[3] Update API documentation
[4] Send release notes

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the &lt;code&gt;start=1&lt;/code&gt; argument. By default, &lt;code&gt;enumerate()&lt;/code&gt; starts counting at 0, which matches Python's zero-based indexing. Passing &lt;code&gt;start=1&lt;/code&gt; instantly adapts the counter for human-facing output without needing clumsy math like &lt;code&gt;priority + 1&lt;/code&gt; inside your display strings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes to Watch For
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Forgetting to advance a counter in &lt;code&gt;while&lt;/code&gt; loops:&lt;/strong&gt; If you use a variable in your condition (like &lt;code&gt;while count &amp;lt; 5:&lt;/code&gt;), make sure you update &lt;code&gt;count&lt;/code&gt; inside the loop body. Forgetting this creates an infinite loop that pins your CPU.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modifying a list while looping over it:&lt;/strong&gt; Removing or adding elements to a list you are currently iterating through causes skipped items and unpredictable behavior. If you need to filter a list, iterate over a copy or build a new list instead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Overusing &lt;code&gt;range(len(...))&lt;/code&gt;:&lt;/strong&gt; If you only need the items, use &lt;code&gt;for item in collection:&lt;/code&gt;. If you need both the index and the item, use &lt;code&gt;enumerate(collection)&lt;/code&gt;. Reaching for &lt;code&gt;range(len(...))&lt;/code&gt; is rarely the most readable choice in Python.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use a &lt;strong&gt;&lt;code&gt;for&lt;/code&gt; loop&lt;/strong&gt; when you have a sequence to traverse or know the number of iterations upfront.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use a &lt;strong&gt;&lt;code&gt;while&lt;/code&gt; loop&lt;/strong&gt; when iterating based on a state or condition that changes dynamically during execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;strong&gt;&lt;code&gt;break&lt;/code&gt;&lt;/strong&gt; to exit a loop immediately when a stopping condition is met.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;strong&gt;&lt;code&gt;continue&lt;/code&gt;&lt;/strong&gt; to skip the rest of the current iteration and move to the next item.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;strong&gt;&lt;code&gt;enumerate()&lt;/code&gt;&lt;/strong&gt; whenever you need item indices alongside their values.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Write small scripts to experiment with loop behavior. Once you can predict how data moves through each cycle, structuring your programs becomes straightforward.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How Python Operators and Conditionals Actually Work (With Real Project Code)</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Thu, 17 Sep 2026 06:37:46 +0000</pubDate>
      <link>https://dev.to/okall_omondi/how-python-operators-and-conditionals-actually-work-with-real-project-code-45og</link>
      <guid>https://dev.to/okall_omondi/how-python-operators-and-conditionals-actually-work-with-real-project-code-45og</guid>
      <description>&lt;p&gt;When I first started writing code, everything felt like a simple sequence: run line one, then run line two, then exit. But real software doesn't run in a straight line. It has to make decisions. &lt;/p&gt;

&lt;p&gt;Did the user input a username and/or password? Is the username correct? Should a user be allowed to sign in? Does a phone number match the format you expect? And many more.&lt;/p&gt;

&lt;p&gt;Answering these questions comes down to two foundational ideas in Python: &lt;strong&gt;operators&lt;/strong&gt; and &lt;strong&gt;conditionals&lt;/strong&gt;. Once you understand how they work together, your scripts stop being static lists of commands and start behaving like real applications.&lt;/p&gt;

&lt;p&gt;Here is what I learned while wrapping my head around them, along with code from a command-line contact book project I built to put these concepts to work.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can also check my previous articles on Python. &lt;a href="https://dev.to/okall_omondi/python-will-save-you-time-here-is-why-and-how-51io"&gt;Python will Save You Time. Here is Why and How&lt;/a&gt; and &lt;a href="https://dev.to/okall_omondi/python-basics-where-it-all-starts-1d12"&gt;Python Basics: Where It All Starts&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  What Are Operators?
&lt;/h2&gt;

&lt;p&gt;Think of operators as the verbs of Python. They take pieces of data (called operands) and do something with them, usually spitting out a brand new value.&lt;/p&gt;

&lt;p&gt;Python has several categories of operators, but three show up constantly when you're controlling program flow: arithmetic, comparison, and logical operators.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Arithmetic Operators
&lt;/h3&gt;

&lt;p&gt;You probably know these from math class: addition (&lt;code&gt;+&lt;/code&gt;), subtraction (&lt;code&gt;-&lt;/code&gt;), multiplication (&lt;code&gt;*&lt;/code&gt;), and division (&lt;code&gt;/&lt;/code&gt;). &lt;/p&gt;

&lt;p&gt;In Python, though, arithmetic operators aren't just for math. They can also manipulate text. For example, multiplying a string repeats it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Outputs: ========================================
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a neat trick for printing clean visual borders in terminal menus without typing forty equals signs by hand.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Comparison Operators
&lt;/h3&gt;

&lt;p&gt;These operators compare two values and always return a Boolean: either &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;==&lt;/code&gt; checks if two values are equal&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;!=&lt;/code&gt; checks if two values are not equal&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt; handle standard less-than and greater-than checks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A classic mistake here is confusing &lt;code&gt;=&lt;/code&gt; with &lt;code&gt;==&lt;/code&gt;. A single equals sign assigns a value to a variable (&lt;code&gt;age = 25&lt;/code&gt;). A double equals sign asks a question (&lt;code&gt;age == 25&lt;/code&gt;). Python will throw a syntax error if you mix these up in an &lt;code&gt;if&lt;/code&gt; statement, but it still trips up almost everyone in the beginning.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Logical Operators
&lt;/h3&gt;

&lt;p&gt;Logical operators let you combine multiple conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;and&lt;/code&gt; returns &lt;code&gt;True&lt;/code&gt; only if &lt;em&gt;both&lt;/em&gt; conditions are true.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;or&lt;/code&gt; returns &lt;code&gt;True&lt;/code&gt; if &lt;em&gt;at least one&lt;/em&gt; condition is true.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;not&lt;/code&gt; reverses the Boolean value (turning &lt;code&gt;True&lt;/code&gt; to &lt;code&gt;False&lt;/code&gt;, and vice versa).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Python reads these almost like plain English, which makes long conditions much easier to decipher.&lt;/p&gt;




&lt;h2&gt;
  
  
  Directing Traffic with Conditionals
&lt;/h2&gt;

&lt;p&gt;Conditionals are where operators get useful. They tell Python: "Only run this block of code if a specific condition evaluates to &lt;code&gt;True&lt;/code&gt;."&lt;/p&gt;

&lt;p&gt;The basic structure uses &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;elif&lt;/code&gt; (short for else-if), and &lt;code&gt;else&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;85&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Grade: A&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Grade: B&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Keep practicing!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python evaluates these from top to bottom. As soon as one condition evaluates to &lt;code&gt;True&lt;/code&gt;, Python executes that indented block and skips the rest of the chain completely.&lt;/p&gt;




&lt;h2&gt;
  
  
  How I Used Them in a Project: The Contact Book
&lt;/h2&gt;

&lt;p&gt;Theory is fine, but seeing these ideas handle messy real-world input is where things click. &lt;/p&gt;

&lt;p&gt;Recently, I built a command-line contact book that stores names and Kenyan phone numbers in a dictionary. The entire program relies on operators and conditionals to route user choices and validate data.&lt;/p&gt;

&lt;p&gt;Here is the core logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;

&lt;span class="n"&gt;contacts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1. Add Contact&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;2. Search Contact&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;3. Delete Contact&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;4. Print All&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;5. Quit&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter your choice (1-5): &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter contact name: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c1"&gt;# Checking for empty strings using "not"
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Name cannot be empty. Please enter a valid name.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="c1"&gt;# Using the "in" membership operator
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Contact &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; already exists. Do you want to update their number? (y/n): &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;n&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="n"&gt;phone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter phone number: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c1"&gt;# Validation checks
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isdigit&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid phone number. Please enter digits only.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+254&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="n"&gt;phone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^(07|01)\d{8}$&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;phone&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Added &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; successfully.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid phone number format. Must start with 07 or 01 and have 10 digits.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter contact name: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Contact not found.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter contact name: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;del&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Contact &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; deleted successfully.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Contact not found.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;4&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Checking truthiness of the contacts dictionary
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;All Contacts:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;phone&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Total contacts: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No contacts to display.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;5&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Goodbye!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid choice, please select 1-5.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break down three specific ways operators and conditionals keep this program from breaking.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Truthiness and the &lt;code&gt;not&lt;/code&gt; Operator
&lt;/h3&gt;

&lt;p&gt;Look at how empty inputs are handled:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Name cannot be empty.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Python, empty structures, like an empty string &lt;code&gt;""&lt;/code&gt;, an empty list &lt;code&gt;[]&lt;/code&gt;, or an empty dictionary &lt;code&gt;{}&lt;/code&gt; are considered "falsy." That means Python treats them as &lt;code&gt;False&lt;/code&gt; in a conditional context.&lt;/p&gt;

&lt;p&gt;If the user hits Enter without typing a name, &lt;code&gt;name&lt;/code&gt; is &lt;code&gt;""&lt;/code&gt;. Python sees that as &lt;code&gt;False&lt;/code&gt;. The &lt;code&gt;not&lt;/code&gt; operator flips that &lt;code&gt;False&lt;/code&gt; to &lt;code&gt;True&lt;/code&gt;, triggering the warning and restarting the loop. &lt;/p&gt;

&lt;p&gt;I used the same concept when printing the directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Print the directory
&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No contacts to display.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of writing &lt;code&gt;if len(contacts) &amp;gt; 0:&lt;/code&gt;, we can test the dictionary directly. If it has items, it is truthy. If it's empty, it evaluates to &lt;code&gt;False&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The &lt;code&gt;in&lt;/code&gt; Membership Operator
&lt;/h3&gt;

&lt;p&gt;Before adding, updating, or deleting a name, the program needs to know if that person already exists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;del&lt;/span&gt; &lt;span class="n"&gt;contacts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;in&lt;/code&gt; is a membership operator. It checks whether a specific key exists inside a collection. Using &lt;code&gt;in&lt;/code&gt; keeps your code readable and saves you from writing manual search loops just to see if a record is there.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Cleaning and Validating Inputs
&lt;/h3&gt;

&lt;p&gt;Real data is unpredictable. Users add extra spaces, enter letters where numbers belong, or use international prefixes instead of local ones. &lt;/p&gt;

&lt;p&gt;The nested conditionals inside option &lt;code&gt;1&lt;/code&gt; act like a filter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;if not phone.isdigit():&lt;/code&gt; catches accidental letters or symbols right away.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;if phone.startswith('+254'):&lt;/code&gt; checks for the Kenyan country code and normalizes it to a local zero (&lt;code&gt;phone = '0' + phone[4:]&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;An inner regular expression check ensures the number begins with &lt;code&gt;07&lt;/code&gt; or &lt;code&gt;01&lt;/code&gt; and contains exactly ten digits.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If any check fails, execution stops early with a clear error message instead of corrupting the dictionary with bad data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Three Common Mistakes to Avoid
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Forgetting that &lt;code&gt;input()&lt;/code&gt; Returns a String
&lt;/h3&gt;

&lt;p&gt;When asking users for numbers, beginners often write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter your age: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Allowed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This crashes with a &lt;code&gt;TypeError&lt;/code&gt;. Even if the user types &lt;code&gt;20&lt;/code&gt;, Python stores it as &lt;code&gt;"20"&lt;/code&gt; (text). You cannot compare text to an integer. You must explicitly convert it using &lt;code&gt;int(input(...))&lt;/code&gt; or keep both sides of your comparison as strings, like I did with &lt;code&gt;choice == '1'&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accidental Assignment
&lt;/h3&gt;

&lt;p&gt;Writing &lt;code&gt;if choice = '1':&lt;/code&gt; instead of &lt;code&gt;if choice == '1':&lt;/code&gt; will stop your script immediately. Assignment gives a variable a value; comparison evaluates a relationship.&lt;/p&gt;

&lt;h3&gt;
  
  
  Over-Nesting Conditionals
&lt;/h3&gt;

&lt;p&gt;It's tempting to put &lt;code&gt;if&lt;/code&gt; statements inside &lt;code&gt;if&lt;/code&gt; statements five levels deep. If you catch yourself indenting four or five times, consider using &lt;code&gt;and&lt;/code&gt; to combine conditions, or use guard clauses (like &lt;code&gt;continue&lt;/code&gt; or &lt;code&gt;return&lt;/code&gt;) to kick out invalid data early.&lt;/p&gt;




&lt;h2&gt;
  
  
  Practical Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use string operators for formatting:&lt;/strong&gt; &lt;code&gt;"=" * 40&lt;/code&gt; keeps your CLI output clean without clutter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lean on truthiness:&lt;/strong&gt; You don't need &lt;code&gt;if len(my_list) == 0:&lt;/code&gt;. A simple &lt;code&gt;if not my_list:&lt;/code&gt; is cleaner and more idiomatic Python.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validate early:&lt;/strong&gt; Check for bad inputs first and exit early. It keeps your main logic clean and easier to maintain.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Remember that &lt;code&gt;=&lt;/code&gt; assigns, while &lt;code&gt;==&lt;/code&gt; compares.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Operators and conditionals are the decision-makers in your scripts. Once you get comfortable combining them, you can handle unexpected input, manage state, and build programs that work reliably. Give a simple CLI tool like this a try—building one teaches you more about logic flow than reading syntax ever will.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Basics: Where It All Starts</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Wed, 16 Sep 2026 05:17:46 +0000</pubDate>
      <link>https://dev.to/okall_omondi/python-basics-where-it-all-starts-1d12</link>
      <guid>https://dev.to/okall_omondi/python-basics-where-it-all-starts-1d12</guid>
      <description>&lt;p&gt;When you decide to learn programming, you run into an immediate wall of jargon: compilers, memory allocation, object-oriented paradigms, and low-level system design. It is enough to make anyone close their laptop and walk away.&lt;/p&gt;

&lt;p&gt;This is where Python changes things. Python was designed around a simple philosophy: readability counts. The syntax reads surprisingly close to plain English, letting you focus on learning how to solve problems with logic rather than wrestling with obscure symbols.&lt;/p&gt;

&lt;p&gt;If you are just getting started, or if you already know another language and want to pick up Python without the fluff, this guide covers the core foundation you will use every day.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Python Syntax Feels Different
&lt;/h2&gt;

&lt;p&gt;Python strips away the visual noise common in other programming languages like C++ and Java. It uses indentation (whitespace) to determine how code blocks are structured, and new lines signify the end of a statement.&lt;/p&gt;

&lt;p&gt;Here is the classic starting point in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, World!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the entire program. The &lt;code&gt;print()&lt;/code&gt; function takes whatever data you pass inside its parentheses and displays it on your terminal screen.&lt;/p&gt;

&lt;h3&gt;
  
  
  Indentation Matters!
&lt;/h3&gt;

&lt;p&gt;Because Python does not rely on braces to group code, spacing is not optional aesthetic formatting. Spacing is an executable part of the language. &lt;/p&gt;

&lt;p&gt;Standard convention is to use four spaces per indentation level. Avoid mixing tabs and spaces in the same file, as Python will raise an &lt;code&gt;IndentationError&lt;/code&gt; if the spacing is inconsistent.&lt;/p&gt;




&lt;h2&gt;
  
  
  Storing Data: Variables and Dynamic Typing
&lt;/h2&gt;

&lt;p&gt;Programs are essentially engines that take data, transform it, and display a result. To work with data, you need a way to label and store it temporarily in your computer's memory. That is what a variable is: a named label pointing to a value.&lt;/p&gt;

&lt;p&gt;In Python, you do not declare a variable type in advance. You simply write the variable name, use the assignment operator (&lt;code&gt;=&lt;/code&gt;), and provide the value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;user_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Navas&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;user_age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;
&lt;span class="n"&gt;account_balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;200145.50&lt;/span&gt;
&lt;span class="n"&gt;is_active&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This behavior is called &lt;strong&gt;dynamic typing&lt;/strong&gt;. Python inspects the value on the right side of the equals sign at runtime and assigns the appropriate data type automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Naming Conventions
&lt;/h3&gt;

&lt;p&gt;Python developers follow a style guide known as PEP 8. For variable names, the standard convention is &lt;code&gt;snake_case&lt;/code&gt;: lowercase letters with words separated by underscores.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Good: &lt;code&gt;total_score&lt;/code&gt;, &lt;code&gt;first_name&lt;/code&gt;, &lt;code&gt;max_limit&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Avoid: &lt;code&gt;TotalScore&lt;/code&gt;, &lt;code&gt;firstName&lt;/code&gt;, &lt;code&gt;x&lt;/code&gt; (unless &lt;code&gt;x&lt;/code&gt; is a standard math variable)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Core Data Types You Will Use Daily
&lt;/h2&gt;

&lt;p&gt;Everything stored in a Python variable has a type. Let us walk through the four primitive types you will interact with constantly.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Integers (&lt;code&gt;int&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Integers represent whole numbers, positive or negative, without a decimal point.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;items_in_cart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;temperature_change&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Floating-Point Numbers (&lt;code&gt;float&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Floats represent real numbers that include a fractional part using a decimal point.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tax_rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.08&lt;/span&gt;
&lt;span class="n"&gt;item_price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;19.99&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep in mind that computers handle floating-point arithmetic using binary approximations. If you calculate &lt;code&gt;0.1 + 0.2&lt;/code&gt;, you might occasionally see &lt;code&gt;0.30000000000000004&lt;/code&gt; rather than an exact &lt;code&gt;0.3&lt;/code&gt;. For everyday scripts, this rarely causes issues, but for financial applications, Python provides a dedicated &lt;code&gt;decimal&lt;/code&gt; module to avoid precision rounding errors.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Strings (&lt;code&gt;str&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Strings are sequences of characters used to store text. You define them using single quotes &lt;code&gt;'...'&lt;/code&gt; or double quotes &lt;code&gt;"..."&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Welcome back!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;file_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;documents/notes.txt&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both styles work identically. The common convention is to pick one style and stay consistent throughout your script, switching only when you need quotes inside the string itself (for example: &lt;code&gt;"Don't forget your keys"&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Booleans (&lt;code&gt;bool&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Booleans represent binary truth values: either &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;. Notice that both start with a capital letter in Python.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;logged_in&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;has_permission&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These become essential later when you write conditional statements (&lt;code&gt;if&lt;/code&gt; / &lt;code&gt;else&lt;/code&gt;) to control the flow of your program based on real-time conditions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Taking Input and Displaying Output
&lt;/h2&gt;

&lt;p&gt;A program becomes truly useful when it interacts with the person using it. You have already seen &lt;code&gt;print()&lt;/code&gt; for output. To capture data from someone using the program, Python provides the built-in &lt;code&gt;input()&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;Here is how input and output work together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What is your name? &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Nice to meet you, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When Python encounters &lt;code&gt;input()&lt;/code&gt;, it pauses execution and waits for the user to type something into the console and press Enter.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Input Type Trap
&lt;/h3&gt;

&lt;p&gt;There is one critical behavior every beginner runs into with &lt;code&gt;input()&lt;/code&gt;: &lt;strong&gt;it always returns user input as a string (&lt;code&gt;str&lt;/code&gt;)&lt;/strong&gt;, even if the user enters digits.&lt;/p&gt;

&lt;p&gt;Consider this snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter your age: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;next_year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# This will trigger a TypeError!
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you enter &lt;code&gt;25&lt;/code&gt;, Python does not see the number &lt;code&gt;25&lt;/code&gt;. It sees the string &lt;code&gt;"25"&lt;/code&gt;. Trying to add an integer to a text string causes Python to throw an error: &lt;code&gt;TypeError: can only concatenate str (not "int") to str&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To fix this, convert the string into a numeric type using &lt;strong&gt;type casting&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter your age: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;age_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;next_year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;age_number&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Next year you will be &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;next_year&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; years old.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;int()&lt;/code&gt; function converts valid text digits into an actual integer. If you expect numbers with decimal points, use &lt;code&gt;float()&lt;/code&gt; instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Formatting Strings with f-Strings
&lt;/h3&gt;

&lt;p&gt;In older Python tutorials, you will see string concatenation with plus signs (&lt;code&gt;"Hello " + name&lt;/code&gt;) or the &lt;code&gt;.format()&lt;/code&gt; method. Modern Python (version 3.6 and newer) uses &lt;strong&gt;f-strings&lt;/strong&gt; (formatted string literals).&lt;/p&gt;

&lt;p&gt;Prefix your string with the letter &lt;code&gt;f&lt;/code&gt;, and you can place any variable or expression directly inside curly brackets &lt;code&gt;{}&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Mechanical Keyboard&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;
&lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Purchased &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; x &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; for a total of Ksh. &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the &lt;code&gt;:.2f&lt;/code&gt; inside the brackets. That is a format specifier that rounds the calculated floating-point total to two decimal places. It is clean, readable, and saves you from converting values manually just to print them.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Working Example: Tip Calculator
&lt;/h2&gt;

&lt;p&gt;Let us combine variables, arithmetic operators, user input, type casting, and f-strings into a practical terminal tool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Simple Bill &amp;amp; Tip Calculator
&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;=== Bill Splitter ===&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Gather input
&lt;/span&gt;&lt;span class="n"&gt;total_bill_str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter the total bill amount: Ksh. &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tip_percentage_str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter tip percentage (e.g., 15, 18, 20): &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;people_count_str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How many people are splitting the bill? &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Convert input strings to appropriate numerical types
&lt;/span&gt;&lt;span class="n"&gt;bill&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total_bill_str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tip_percent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tip_percentage_str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;people&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;people_count_str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Perform the calculations
&lt;/span&gt;&lt;span class="n"&gt;tip_amount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bill&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tip_percent&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;final_total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bill&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;tip_amount&lt;/span&gt;
&lt;span class="n"&gt;cost_per_person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;final_total&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt;

&lt;span class="c1"&gt;# Display the results
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;--- Summary ---&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Total tip: Ksh. &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;tip_amount&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Final bill: Ksh. &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;final_total&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Each person pays: Ksh. &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;cost_per_person&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run this code, you have built a complete, interactive utility using nothing more than basic variables, type conversion, and standard input/output.&lt;/p&gt;




&lt;h2&gt;
  
  
  Three Mistakes to Watch Out For
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting that variable names are case-sensitive.&lt;/strong&gt; &lt;code&gt;score&lt;/code&gt;, &lt;code&gt;Score&lt;/code&gt;, and &lt;code&gt;SCORE&lt;/code&gt; are three distinct variables in Python. If you create a variable named &lt;code&gt;user_input&lt;/code&gt; and later try to print &lt;code&gt;User_input&lt;/code&gt;, Python will stop and report a &lt;code&gt;NameError&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Confusing &lt;code&gt;=&lt;/code&gt; with &lt;code&gt;==&lt;/code&gt;.&lt;/strong&gt; A single equals sign (&lt;code&gt;=&lt;/code&gt;) assigns a value to a variable. A double equals sign (&lt;code&gt;==&lt;/code&gt;) compares two values to see if they are equal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaving out type conversion after &lt;code&gt;input()&lt;/code&gt;.&lt;/strong&gt; If you plan on doing any math with user-provided information, cast it to &lt;code&gt;int()&lt;/code&gt; or &lt;code&gt;float()&lt;/code&gt; immediately.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python prioritizes clean, readable syntax and uses indentation rather than curly braces to define scope.&lt;/li&gt;
&lt;li&gt;Variables do not require explicit type definitions; Python handles typing dynamically at assignment.&lt;/li&gt;
&lt;li&gt;The core primitive types are integers (&lt;code&gt;int&lt;/code&gt;), floating-point numbers (&lt;code&gt;float&lt;/code&gt;), strings (&lt;code&gt;str&lt;/code&gt;), and booleans (&lt;code&gt;bool&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;input()&lt;/code&gt; always captures text as a string; use &lt;code&gt;int()&lt;/code&gt; or &lt;code&gt;float()&lt;/code&gt; when you need numbers.&lt;/li&gt;
&lt;li&gt;Formatted string literals (&lt;code&gt;f"..."&lt;/code&gt;) are the cleanest and most efficient way to embed variables inside strings.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  My Take
&lt;/h2&gt;

&lt;p&gt;Writing code is less about memorizing syntax rules and more about building a habit of breaking problems into small, logical steps. With variables, types, and input/output under your belt, you have the groundwork needed to start exploring decision logic, loops, and custom functions. Fire up a terminal, experiment with the tip calculator, tweak the formulas, and see what happens. And don't forget to practice, practice, practice and practice!&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python will Save You Time. Here is Why and How.</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Tue, 15 Sep 2026 05:14:00 +0000</pubDate>
      <link>https://dev.to/okall_omondi/python-will-save-you-time-here-is-why-and-how-51io</link>
      <guid>https://dev.to/okall_omondi/python-will-save-you-time-here-is-why-and-how-51io</guid>
      <description>&lt;p&gt;When you decide to learn to program, the first hurdle isn't a tricky concept or a confusing line of syntax. It is the overwhelming paradox of choice. You run into dozens of languages: C++, JavaScript, Go, Rust, Java, and Python. Every forum insists a different one is the absolute best starting point.&lt;/p&gt;

&lt;p&gt;If your goal is to build things quickly, automate boring everyday tasks, or make sense of data, the debate usually ends right where it begins: with Python.&lt;/p&gt;

&lt;p&gt;Let's look at why Python continues to dominate developer surveys, why it quietly took over the data science industry, and whether it makes sense for your specific goals.&lt;/p&gt;




&lt;h2&gt;
  
  
  Code That Actually Looks Like English
&lt;/h2&gt;

&lt;p&gt;The biggest barrier for newcomers isn't logic; it's notation. &lt;/p&gt;

&lt;p&gt;Many classic programming languages demand significant boilerplate code just to say hello. In Java or C++, printing a simple message involves defining classes, writing method signatures, managing memory scopes, and placing semicolons after every instruction. Miss a bracket, and the entire program halts with an error message that looks like ancient script.&lt;/p&gt;

&lt;p&gt;Python took a completely different design path. Its creator, Guido van Rossum, believed that code is read far more often than it is written. &lt;/p&gt;

&lt;p&gt;Consider how you display text on a screen in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, world!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the entire program. No boilerplate, no headers, no memory management setup.&lt;/p&gt;

&lt;p&gt;Python enforces readability by making indentation part of the syntax itself. In most languages, spaces and tabs are just stylistic preferences. In Python, an indent defines a block of related code. This constraint forces everyone, from hobbyists to senior engineers, to write clean, legible code that you can still decipher six months later.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Mental Shift: From Mechanics to Problem-Solving
&lt;/h2&gt;

&lt;p&gt;Every programming language requires you to juggle two things at once:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The logic:&lt;/strong&gt; How do I solve this problem?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The syntax:&lt;/strong&gt; How do I express this solution so the compiler accepts it?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When you work in lower-level languages, syntax often consumes 70% of your attention. You spend mental bandwidth worrying about pointer arithmetic, static type definitions, and manual memory allocation. &lt;/p&gt;

&lt;p&gt;Python flips those priorities. Because the syntax stays out of your way, you spend your time thinking about the actual problem you set out to solve. &lt;/p&gt;

&lt;p&gt;If you want to read a text file line by line, you write code that mirrors that thought:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notes.txt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This clarity creates a positive feedback loop. Instead of spending an afternoon troubleshooting cryptic compilation errors, you see working results within minutes. That immediate feedback is what keeps beginners engaged long enough to build real competence.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Python Owns Data Science
&lt;/h2&gt;

&lt;p&gt;Python is versatile, it powers web backends, workflow automation, and game scripts. But its strongest foothold is in data analysis, machine learning, and scientific research. &lt;/p&gt;

&lt;p&gt;How did a general-purpose language beat out specialized statistical languages like R, SAS, or MATLAB? It comes down to two structural advantages.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The Modular Ecosystem
&lt;/h3&gt;

&lt;p&gt;Python’s standard library comes with plenty of built-in tools. However, its real power comes from community-developed libraries. A library is simply a collection of pre-written functions you can plug into your project so you don't have to reinvent the wheel.&lt;/p&gt;

&lt;p&gt;In the data world, Python offers a cohesive toolkit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NumPy:&lt;/strong&gt; Handles heavy mathematical operations and multi-dimensional arrays at lightning speed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pandas:&lt;/strong&gt; Provides data structures that make filtering, grouping, and reshaping tabular datasets as straightforward as working in an Excel spreadsheet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Matplotlib &amp;amp; Seaborn:&lt;/strong&gt; Turn raw columns of numbers into clear charts and visualizations with a few lines of instructions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scikit-Learn:&lt;/strong&gt; Gives you access to industry-standard machine learning algorithms through clean, consistent interfaces.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because these tools share design philosophies, they fit together cleanly. You can load messy records using Pandas, run a statistical calculation with NumPy, and graph the pattern with Seaborn, all within the same 15 lines of script. How awesome is that?&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Fast Development Over Fast Execution
&lt;/h3&gt;

&lt;p&gt;A common criticism from systems engineers is that Python is slow compared to compiled languages like C or Rust. Technically, they are correct. Python is an interpreted language, which introduces execution overhead.&lt;/p&gt;

&lt;p&gt;Here is the trade-off that industry learned the hard way: &lt;strong&gt;developer time is almost always more expensive than CPU time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If an algorithm written in C takes 2 milliseconds to run, but requires three days to write and debug, while the Python version takes 20 milliseconds to run and two hours to build, Python wins in most business scenarios.&lt;/p&gt;

&lt;p&gt;More importantly, the data science community solved the speed problem through smart engineering. Heavy computation libraries like &lt;code&gt;NumPy&lt;/code&gt; and &lt;code&gt;PyTorch&lt;/code&gt; are written in optimized C, C++, or CUDA under the hood. Python simply acts as the friendly steering wheel controlling an engine built for raw performance. You get high-level readability without sacrificing the muscle needed to process millions of rows.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Traps to Watch Out For
&lt;/h2&gt;

&lt;p&gt;While Python is forgiving, it isn't completely frictionless. As you spend more time with the language, keep these three nuances in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic typing can bite you:&lt;/strong&gt; In Python, a variable can hold a number on one line and a string of text on the next. This flexibility is great for fast prototyping, but it can hide bugs in larger applications. Learning to use type hints (&lt;code&gt;def calculate_tax(amount: float) -&amp;gt; float:&lt;/code&gt;) will save you countless headaches down the road.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Indentation errors are real errors:&lt;/strong&gt; Because spacing carries structural meaning, mixing tabs and spaces will trigger errors. Stick to a modern editor like VS Code that automatically inserts four spaces whenever you press the Tab key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tutorial purgatory:&lt;/strong&gt; Because Python is approachable, beginners often get stuck watching endless video series without building anything independently. Write your own tiny scripts early on, even if it's just a tool to rename twenty downloaded files at once. &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Fun Fact: I use Python to organize my files in the Download folder in my PC. &lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Direct Route Forward
&lt;/h2&gt;

&lt;p&gt;Python isn't popular because of clever marketing; it earned its position because it respects your time. It strips away technical friction so you can focus on data, logic, and solutions.&lt;/p&gt;

&lt;p&gt;If you are starting out, don't worry about mastering every feature of the language. Install Python, learn the basics of variables, loops, and functions, and then immediately pick a project that interests you. Build a simple data dashboard, scrape a table off a public webpage, or automate a repetitive work report. &lt;/p&gt;

&lt;h2&gt;
  
  
  My Take
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The syntax will stick naturally once you use it to solve problems you actually care about. You will learn faster by doing, not by watching tutorials.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>python</category>
      <category>datascience</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learning SQL? Here is a Practical Guide to Read and Write SQL Queries.</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Mon, 07 Sep 2026 15:05:58 +0000</pubDate>
      <link>https://dev.to/okall_omondi/getting-started-with-sql-the-practical-guide-to-reading-and-writing-queries-3gg8</link>
      <guid>https://dev.to/okall_omondi/getting-started-with-sql-the-practical-guide-to-reading-and-writing-queries-3gg8</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Every web application, BI dashboard, and digital checkout system has one thing in common: it runs on data. User profiles, product inventories, and transaction logs have to live somewhere durable, and that somewhere is almost always a relational database. &lt;/p&gt;

&lt;p&gt;To get that data out, you need to talk to the database in a language it understands. That language is SQL.&lt;/p&gt;

&lt;p&gt;If you have never written a line of code in your life, SQL is arguably the gentlest entry point into tech. It reads shockingly close to plain English, and unlike other general-purpose languages such as Python, you don't need to instruct the computer how to loop through lists or manage memory. You simply describe what data you want, and the database figures out how to retrieve it.&lt;/p&gt;

&lt;p&gt;Let's walk through how it works, how a query is structured, and how you can write your first one today.&lt;/p&gt;




&lt;h2&gt;
  
  
  What SQL Actually Is
&lt;/h2&gt;

&lt;p&gt;SQL stands for Structured Query Language. People pronounce it either as three individual letters ("S-Q-L") or as "sequel." Both are widely accepted across engineering teams, so use whichever feels natural.&lt;/p&gt;

&lt;p&gt;At its core, SQL is a domain-specific language designed to manage and retrieve data stored in a relational database management system (RDBMS). Popular examples of these systems include PostgreSQL, MySQL, SQLite, and Microsoft SQL Server. &lt;/p&gt;

&lt;p&gt;While each system has slight dialect differences, the baseline syntax remains remarkably consistent. Once you learn standard SQL, switching between MySQL and PostgreSQL feels like moving between different dialects of English: a few spelling tweaks and regional idioms, but the underlying grammar is identical.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Data Is Organized
&lt;/h3&gt;

&lt;p&gt;Before querying data, you need a mental model of where it lives. &lt;/p&gt;

&lt;p&gt;Think of a relational database as a collection of spreadsheets. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;database&lt;/strong&gt; is the entire workbook.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;table&lt;/strong&gt; is a single sheet within that workbook.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;column&lt;/strong&gt; represents a specific category or attribute (such as &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;first_name&lt;/code&gt;, or &lt;code&gt;created_at&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;row&lt;/strong&gt; (often called a record) is a single entry across those columns (one specific user or one distinct order).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you write a query, you are simply asking the database to open a specific sheet, inspect its columns, and hand back the rows that match your criteria.&lt;/p&gt;




&lt;h2&gt;
  
  
  Anatomy of a SQL Query
&lt;/h2&gt;

&lt;p&gt;A SQL statement consists of reserved keywords combined with the names of your tables and columns. &lt;/p&gt;

&lt;p&gt;Consider a practical scenario: you have a table named &lt;code&gt;customers&lt;/code&gt;, and you want to view the first names and email addresses of everyone in that table.&lt;/p&gt;

&lt;p&gt;Here is what that query looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice a few conventions right away:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Keywords are capitalized:&lt;/strong&gt; &lt;code&gt;SELECT&lt;/code&gt; and &lt;code&gt;FROM&lt;/code&gt; are commands built into the language. Capitalizing them is not strictly required by most database engines, but doing so makes your code substantially easier to read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Column names are separated by commas:&lt;/strong&gt; You list the exact fields you want back, separated by a comma.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The statement ends with a semicolon:&lt;/strong&gt; In SQL, the semicolon acts like a period at the end of a sentence. It tells the engine that your instruction is complete.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you wanted to inspect every single column in the table without typing out every field name, you can use the asterisk wildcard:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;A quick word of caution from experience: using &lt;code&gt;SELECT *&lt;/code&gt; is convenient when exploring a new dataset on your local laptop, but it becomes a performance bottleneck in production systems with millions of rows and dozens of columns. Get into the habit of asking only for what you actually need.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Filtering Data with the WHERE Clause
&lt;/h2&gt;

&lt;p&gt;Pulling every record from a table is rarely useful in the real world. Usually, you want answers to specific questions: Which customers live in Nairobi? Which orders were placed today? Which accounts are inactive?&lt;/p&gt;

&lt;p&gt;To filter rows, add a &lt;code&gt;WHERE&lt;/code&gt; clause:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Nairobi'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When filtering text values (strings), wrap the text in single quotes. Numbers, on the other hand, do not take quotes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Combining Conditions
&lt;/h3&gt;

&lt;p&gt;Real-world questions often have multiple layers. You can chain conditions together using &lt;code&gt;AND&lt;/code&gt;, &lt;code&gt;OR&lt;/code&gt;, and &lt;code&gt;NOT&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;AND&lt;/code&gt; requires both conditions to be true:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stock_quantity&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;stock_quantity&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;OR&lt;/code&gt; requires at least one condition to be true:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt;
  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Nairobi'&lt;/span&gt; &lt;span class="k"&gt;OR&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Kisumu'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;IN&lt;/code&gt; handles lists cleanly:&lt;/strong&gt; Instead of stringing together six different &lt;code&gt;OR&lt;/code&gt; checks, you can test membership against a list:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt;
  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Nairobi'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Kisumu'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Mombasa'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Sorting and Limiting Results
&lt;/h2&gt;

&lt;p&gt;Databases do not store records in any guaranteed default order. If you run a query twice, the rows might return in a different sequence unless you explicitly tell the database how to arrange them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ordering Rows
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;ORDER BY&lt;/code&gt; clause lets you sort by one or more columns, either ascending (&lt;code&gt;ASC&lt;/code&gt;, the default) or descending (&lt;code&gt;DESC&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns your product inventory starting with the most expensive item.&lt;/p&gt;

&lt;h3&gt;
  
  
  Restricting the Row Count
&lt;/h3&gt;

&lt;p&gt;When you only care about top performers or want a quick sample of the data, pair &lt;code&gt;ORDER BY&lt;/code&gt; with &lt;code&gt;LIMIT&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have a clean list of your five most expensive products.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden Rule: Written Order vs. Execution Order
&lt;/h2&gt;

&lt;p&gt;Here is something that catches almost every newcomer off guard: &lt;strong&gt;the order in which you write a SQL query is not the order in which the database executes it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you write a query, standard syntax requires this sequence:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;SELECT&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;FROM&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;WHERE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ORDER BY&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;LIMIT&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Under the hood, however, the database processes your instructions in a completely different order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;FROM&lt;/code&gt;&lt;/strong&gt;: First, it locates the target table on disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;WHERE&lt;/code&gt;&lt;/strong&gt;: Next, it evaluates your filters and discards rows that do not match.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;SELECT&lt;/code&gt;&lt;/strong&gt;: Then, it extracts the requested columns from the remaining rows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ORDER BY&lt;/code&gt;&lt;/strong&gt;: It sorts those extracted values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;LIMIT&lt;/code&gt;&lt;/strong&gt;: Finally, it trims the result set to the requested count.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Understanding this sequence prevents endless debugging headaches down the road, particularly when you begin using aliases and aggregate functions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Mistakes Beginners Make
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mixing up single quotes and backticks:&lt;/strong&gt; Use single quotes (&lt;code&gt;'text'&lt;/code&gt;) for literal string values. Backticks or double quotes are reserved in some dialects for table and column names that contain spaces or special characters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting that &lt;code&gt;NULL&lt;/code&gt; means unknown:&lt;/strong&gt; Missing data in SQL is represented as &lt;code&gt;NULL&lt;/code&gt;. Because &lt;code&gt;NULL&lt;/code&gt; signifies the absence of a value, it cannot be equal or unequal to anything. Writing &lt;code&gt;WHERE status = NULL&lt;/code&gt; will never return any rows. You must write &lt;code&gt;WHERE status IS NULL&lt;/code&gt; or &lt;code&gt;WHERE status IS NOT NULL&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trailing commas in &lt;code&gt;SELECT&lt;/code&gt; lists:&lt;/strong&gt; Placing a comma after the final column in your &lt;code&gt;SELECT&lt;/code&gt; clause (for example, &lt;code&gt;SELECT id, name, FROM users;&lt;/code&gt;) is an immediate syntax error in nearly every SQL engine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treating case sensitivity carelessly:&lt;/strong&gt; While SQL keywords (&lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;FROM&lt;/code&gt;) are case-insensitive, text comparisons within single quotes often are case-sensitive depending on your database configuration. &lt;code&gt;'Nairobi'&lt;/code&gt; and &lt;code&gt;'nairobi'&lt;/code&gt; may not match.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;SQL is a declarative language: you specify the data you want, not the step-by-step algorithms required to fetch it.&lt;/li&gt;
&lt;li&gt;A standard read query follows a strict written template: &lt;code&gt;SELECT&lt;/code&gt; columns &lt;code&gt;FROM&lt;/code&gt; a table &lt;code&gt;WHERE&lt;/code&gt; conditions apply.&lt;/li&gt;
&lt;li&gt;The query execution engine reads &lt;code&gt;FROM&lt;/code&gt; and &lt;code&gt;WHERE&lt;/code&gt; before it ever looks at &lt;code&gt;SELECT&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Always use &lt;code&gt;IS NULL&lt;/code&gt; and &lt;code&gt;IS NOT NULL&lt;/code&gt; when checking for empty fields rather than standard equality operators.&lt;/li&gt;
&lt;li&gt;Request only the columns and rows you actually need to keep queries fast and clean.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;Reading about syntax only gets you so far. The fastest way to build intuition for SQL is to sit down in front of a real dataset and start breaking things.&lt;/p&gt;

&lt;p&gt;You do not need to install complicated database servers on your computer to begin. Web tools like SQLite Online or DB-Fiddle give you a sandboxed database directly in your browser. You can also check SQL Bolt for free interactive lessons. Load in a simple sample dataset, start asking basic questions using &lt;code&gt;SELECT&lt;/code&gt; and &lt;code&gt;WHERE&lt;/code&gt;, and see how the database responds. Once the core grammar clicks, you will have a durable, transferable skill that remains relevant across every corner of the software industry.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>A practical, beginner-friendly guide to understanding Python's core data structures: lists, tuples, sets, and dictionaries.</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Mon, 07 Sep 2026 14:04:50 +0000</pubDate>
      <link>https://dev.to/okall_omondi/a-practical-beginner-friendly-guide-to-understanding-pythons-core-data-structures-lists-tuples-2cm5</link>
      <guid>https://dev.to/okall_omondi/a-practical-beginner-friendly-guide-to-understanding-pythons-core-data-structures-lists-tuples-2cm5</guid>
      <description>&lt;p&gt;When you write a program, you quickly run into a basic challenge: where do you put all your data?&lt;/p&gt;

&lt;p&gt;Holding a single number or a single line of text in a variable is simple enough. But real software deals with collections such as customer records, shopping carts, daily temperatures, or user permissions. To manage those effectively, you need structured ways to organize information in memory.&lt;/p&gt;

&lt;p&gt;In Python, four built-in tools handle almost all of this heavy lifting: lists, tuples, sets, and dictionaries. Each has distinct traits, rules, and strengths. Choosing the right one makes your code cleaner, faster, and much less prone to subtle bugs.&lt;/p&gt;

&lt;p&gt;Let's look at how each one works, how they differ, and when to reach for them.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Big Idea: Mutability and Order
&lt;/h2&gt;

&lt;p&gt;Before looking at individual syntax, two terms will come up repeatedly: &lt;strong&gt;order&lt;/strong&gt; and &lt;strong&gt;mutability&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ordered&lt;/strong&gt; means the collection remembers the sequence in which you added items. If an item is at index &lt;code&gt;0&lt;/code&gt;, it stays at index &lt;code&gt;0&lt;/code&gt; until you explicitly move or remove it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mutable&lt;/strong&gt; means you can change the collection after creating it. You can add items, remove items, or overwrite existing values without recreating the container from scratch. &lt;strong&gt;Immutable&lt;/strong&gt; means the opposite: once defined, its contents are locked.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keeping those two concepts in mind makes the differences between Python's core data structures immediately obvious.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Lists: The Versatile Workhorse
&lt;/h2&gt;

&lt;p&gt;A list is an ordered, mutable collection of items. In Python, you define a list using square brackets &lt;code&gt;[]&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;go to the gym&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;reply to emails&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;write report&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because lists are ordered, every element gets an index starting at zero. You can grab the first task with &lt;code&gt;tasks[0]&lt;/code&gt; or append something new to the end using &lt;code&gt;.append()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;call plumber&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;send invoices&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;# overwriting an existing item
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  When to Use a List
&lt;/h3&gt;

&lt;p&gt;Use a list when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You care about the order of your items.&lt;/li&gt;
&lt;li&gt;You expect the collection to grow, shrink, or change while your program runs.&lt;/li&gt;
&lt;li&gt;You have duplicate entries (lists have no problem storing identical values multiple times).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Tuples: The Permanent Record
&lt;/h2&gt;

&lt;p&gt;A tuple looks very similar to a list, but with one critical difference: it cannot be altered after creation. Tuples are defined using parentheses &lt;code&gt;()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;screen_resolution&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1920&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1080&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;gps_coordinates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;37.7749&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;122.4194&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you try to run &lt;code&gt;gps_coordinates[0] = 40.7128&lt;/code&gt;, Python will stop you with a &lt;code&gt;TypeError&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Why would you want a container that refuses to change? &lt;/p&gt;

&lt;p&gt;First, safety. If a piece of data represents fixed configuration settings, database IDs, or coordinate pairs, making it a tuple ensures another function cannot accidentally modify it. &lt;/p&gt;

&lt;p&gt;Second, performance and memory. Tuples take up slightly less memory and can be slightly faster to create than lists because Python knows their size will never change.&lt;/p&gt;

&lt;h3&gt;
  
  
  When to Use a Tuple
&lt;/h3&gt;

&lt;p&gt;Use a tuple when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your data should remain constant throughout the program's lifecycle.&lt;/li&gt;
&lt;li&gt;You need to group a fixed set of related values together, like &lt;code&gt;(red, green, blue)&lt;/code&gt; color codes.&lt;/li&gt;
&lt;li&gt;You need to use a sequence as a dictionary key (lists cannot be dictionary keys, but tuples can).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Sets: The Filter for Uniques
&lt;/h2&gt;

&lt;p&gt;A set is an unordered collection of unique elements. You create a set using curly braces &lt;code&gt;{}&lt;/code&gt; or the &lt;code&gt;set()&lt;/code&gt; constructor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;python&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;programming&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;backend&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sets behave like mathematical sets. They carry two defining characteristics:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No duplicates allowed.&lt;/strong&gt; If you add &lt;code&gt;"python"&lt;/code&gt; a second time, the set silently ignores it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No reliable index.&lt;/strong&gt; Because items aren't stored in a specific order, you cannot access items using index syntax like &lt;code&gt;tags[0]&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;raw_user_ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;102&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;103&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;104&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;102&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;unique_ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw_user_ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# unique_ids is now {101, 102, 103, 104}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sets also shine when comparing groups of data using mathematical operations like unions, intersections, and differences:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;frontend_devs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Alice&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bob&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Charlie&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;backend_devs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bob&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;David&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Edward&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Find people who work on both
&lt;/span&gt;&lt;span class="n"&gt;fullstack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;frontend_devs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;intersection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;backend_devs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# {"Bob"}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  When to Use a Set
&lt;/h3&gt;

&lt;p&gt;Use a set when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need to strip duplicates from existing data.&lt;/li&gt;
&lt;li&gt;You frequently check whether an item exists in a large collection. Checking &lt;code&gt;item in my_set&lt;/code&gt; runs in constant time ($O(1)$), whereas searching a list requires Python to scan items one by one ($O(n)$).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Dictionaries: Labeling Your Data
&lt;/h2&gt;

&lt;p&gt;Lists, tuples, and sets hold individual values. A dictionary stores associations: &lt;strong&gt;key-value pairs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Like sets, dictionaries use curly braces, but each entry consists of a key, a colon, and an associated value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;user_profile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;username&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;alex99&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;alex@example.com&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;login_count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;is_active&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of remembering that an email address was stored at index &lt;code&gt;1&lt;/code&gt; in a list, you look it up directly by its label:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_profile&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;user_profile&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;login_count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keys must be unique and immutable (strings, numbers, or tuples). Values can be anything you want, including other lists or nested dictionaries.&lt;/p&gt;

&lt;h3&gt;
  
  
  When to Use a Dictionary
&lt;/h3&gt;

&lt;p&gt;Use a dictionary when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have structured records where every value has a distinct meaning or label.&lt;/li&gt;
&lt;li&gt;You need fast lookups based on an identifier, such as matching a product ID to inventory details.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Quick Comparison
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Structure&lt;/th&gt;
&lt;th&gt;Syntax&lt;/th&gt;
&lt;th&gt;Ordered?&lt;/th&gt;
&lt;th&gt;Mutable?&lt;/th&gt;
&lt;th&gt;Allows Duplicates?&lt;/th&gt;
&lt;th&gt;Common Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;List&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[1, 2, 3]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;General collections that change&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tuple&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;(1, 2, 3)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Fixed, protected records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Set&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{1, 2, 3}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Uniqueness and membership checks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dictionary&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{"a": 1, "b": 2}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Yes*&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Keys: No / Values: Yes&lt;/td&gt;
&lt;td&gt;Keyed lookups and structured objects&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;*Note: Starting in Python 3.7+, dictionaries officially maintain insertion order.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Beginner Mistakes to Avoid
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Creating an Empty Set with &lt;code&gt;{}&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Writing &lt;code&gt;{}&lt;/code&gt; does not create an empty set. Python defaults to creating an empty dictionary for historical reasons. To create an empty set, always call &lt;code&gt;set()&lt;/code&gt; directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;empty_dict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;       &lt;span class="c1"&gt;# This is a dictionary
&lt;/span&gt;&lt;span class="n"&gt;empty_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;     &lt;span class="c1"&gt;# This is a set
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Modifying a List While Looping Over It
&lt;/h3&gt;

&lt;p&gt;Removing items from a list while iterating over it often causes the loop to skip elements because the underlying indices shift underneath Python's iterator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Problematic:
&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Skips elements unexpectedly
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need to filter a list, create a new one using a list comprehension instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Clean and predictable:
&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Missing the Single-Item Tuple Comma
&lt;/h3&gt;

&lt;p&gt;To define a tuple with a single item, you must include a trailing comma. Without it, Python treats the parentheses as grouping syntax around a plain expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;not_a_tuple&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;admin&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# Type: str
&lt;/span&gt;&lt;span class="n"&gt;is_a_tuple&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;admin&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,)&lt;/span&gt;   &lt;span class="c1"&gt;# Type: tuple
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Choosing with Confidence
&lt;/h2&gt;

&lt;p&gt;Learning these data structures is less about memorizing syntax and more about recognizing the shape of your data.&lt;/p&gt;

&lt;p&gt;Whenever you prepare to store a group of values, pause and ask yourself three questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do these values have meaningful labels? If yes, reach for a &lt;strong&gt;dictionary&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Does the order matter, and will the values change? If yes, pick a &lt;strong&gt;list&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Do you need strict uniqueness, or do you need to protect fixed values from accidental modification? Pick a &lt;strong&gt;set&lt;/strong&gt; or a &lt;strong&gt;tuple&lt;/strong&gt;, respectively.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Get comfortable matching these tools to your problem, and writing clear, efficient Python becomes second nature.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Connecting Power BI to SQL Databases: Local SQL Server and Aiven PostgreSQL (SSL) Using DBeaver</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Sun, 12 Jul 2026 08:55:35 +0000</pubDate>
      <link>https://dev.to/okall_omondi/connecting-power-bi-to-sql-databases-local-sql-server-and-aiven-postgresql-ssl-using-dbeaver-30hf</link>
      <guid>https://dev.to/okall_omondi/connecting-power-bi-to-sql-databases-local-sql-server-and-aiven-postgresql-ssl-using-dbeaver-30hf</guid>
      <description>&lt;p&gt;If you're learning Power BI, one of the first practical skills you need is connecting it to a database. Most tutorials stop after showing a simple SQL Server connection, but real projects are rarely that simple. Sometimes the database is running on your own machine. Other times it lives in the cloud and requires SSL certificates before Power BI will even talk to it. &lt;/p&gt;

&lt;p&gt;In this guide, I'll walk through both scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Connecting Power BI to a local SQL Server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connecting Power BI to an Aiven PostgreSQL database using SSL, with DBeaver helping us verify the connection first.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is not just to make the connection work, but to understand why each step matters so you can troubleshoot issues later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before You Start
&lt;/h3&gt;

&lt;p&gt;You should have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.microsoft.com/en-us/download/details.aspx?id=58494" rel="noopener noreferrer"&gt;Power BI Desktop&lt;/a&gt; installed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PostreSQL Server installed locally.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dbeaver.io/download/" rel="noopener noreferrer"&gt;DBeaver&lt;/a&gt; installed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F46jgn6qvq8np7lar63aq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F46jgn6qvq8np7lar63aq.png" alt=" " width="799" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An &lt;a href="https://aiven.io/" rel="noopener noreferrer"&gt;Aiven&lt;/a&gt; PostgreSQL service powered on and running.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fol30bb9cjqnrn8id0vpb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fol30bb9cjqnrn8id0vpb.png" alt=" " width="799" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The SSL certificate file downloaded from Aiven, usually named &lt;code&gt;ca.pem&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DBeaver is useful because it lets you confirm that the database itself is reachable before involving Power BI. If DBeaver cannot connect, Power BI almost certainly won't either.&lt;/p&gt;

&lt;h3&gt;
  
  
  Part 1: Connecting Power BI to a Local SQL Server
&lt;/h3&gt;

&lt;p&gt;Let's start with the easier case.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Find Your SQL Server Name
&lt;/h3&gt;

&lt;p&gt;Open SQL Server Management Studio (SSMS) if you have it installed, or check the SQL Server services list.&lt;/p&gt;

&lt;p&gt;Common server names look like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;localhost&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;localhost\SQLEXPRESS&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;DESKTOP-ABC123\SQLEXPRESS&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If you're using SQL Server Express, the &lt;code&gt;\SQLEXPRESS&lt;/code&gt; part is often required.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Step 2: Open Power BI
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Launch Power BI Desktop.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select Get Data → SQL Server.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnrjrz1qd75rckdnhjzgd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnrjrz1qd75rckdnhjzgd.png" alt=" " width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Enter Connection Details
&lt;/h3&gt;

&lt;p&gt;Fill in:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Server&lt;/td&gt;
&lt;td&gt;127.0.0.1:0000 (localhost IP Adress:port_number)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;postres in my case or leave blank to see all databases, or enter a specific database name.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Choose Import mode for beginners. It loads data into Power BI and is easier to work with than DirectQuery.&lt;/p&gt;

&lt;p&gt;Click OK.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Authenticate
&lt;/h3&gt;

&lt;p&gt;Power BI will ask how to log in.&lt;/p&gt;

&lt;p&gt;For a local development machine, Windows authentication is usually the simplest option because it uses your current Windows account.&lt;/p&gt;

&lt;p&gt;If your SQL Server uses SQL logins instead, choose Database and enter the username and password.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Select Tables
&lt;/h3&gt;

&lt;p&gt;After connecting, Power BI shows the available tables and views.&lt;/p&gt;

&lt;p&gt;Select the tables you need and click Load.&lt;/p&gt;

&lt;p&gt;At this point, your local SQL Server is connected and ready for reporting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Part 2: Verify Aiven PostgreSQL in DBeaver First
&lt;/h3&gt;

&lt;p&gt;Cloud databases introduce one extra requirement: SSL encryption.&lt;/p&gt;

&lt;p&gt;Aiven provides PostgreSQL over an encrypted connection, which means Power BI needs the same certificate information that DBeaver uses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create the Connection in DBeaver
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open DBeaver.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click New Database Connection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose PostgreSQL.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enter the connection details from your Aiven dashboard:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Host&lt;/td&gt;
&lt;td&gt;pg-12345.aivencloud.com&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Port&lt;/td&gt;
&lt;td&gt;12345&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;defaultdb&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User&lt;/td&gt;
&lt;td&gt;Your Aiven username&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password&lt;/td&gt;
&lt;td&gt;Your Aiven password&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 2: Configure SSL
&lt;/h3&gt;

&lt;p&gt;From the Aiven dashboard, download the CA certificate&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7ny6yjhqjd3umr72bn9c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7ny6yjhqjd3umr72bn9c.png" alt=" " width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On your windows PC launch Microsoft Management Console by typing &lt;code&gt;mmc&lt;/code&gt; in the search console, and add the certificate snap-in by clicking on File --&amp;gt; Add/Remove Snap-in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5s3cdop969ltrvhebnou.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5s3cdop969ltrvhebnou.png" alt=" " width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Restart Power BI if you had it open to ensure the SSL certificate is loaded.&lt;/p&gt;

&lt;h3&gt;
  
  
  Part 3: Connect Power BI to Aiven PostgreSQL with SSL
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Step 1: Install the PostgreSQL Connector if Needed
&lt;/h3&gt;

&lt;p&gt;Recent versions of Power BI already include it. If Power BI prompts you to install the PostgreSQL driver, follow the prompt and restart Power BI.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Start the Connection
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Select Get Data → PostgreSQL database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcql7u3lezaxtuz63mwlk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcql7u3lezaxtuz63mwlk.png" alt=" " width="799" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enter the server as &lt;code&gt;host:port&lt;/code&gt; from the aiven connection information section.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pg-12345.aivencloud.com:12345&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enter the database name, such as &lt;code&gt;defaultdb&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Configure SSL in Power BI
&lt;/h3&gt;

&lt;p&gt;When the authentication window appears:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Choose Database authentication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter your Aiven username and password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand Advanced options if available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set SSL Mode to &lt;code&gt;verify-full&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Browse to the same &lt;code&gt;ca.pem&lt;/code&gt; certificate used in DBeaver.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3y7wh0gg9l07nx1b6fwe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3y7wh0gg9l07nx1b6fwe.png" alt=" " width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click Connect.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Load the Data
&lt;/h3&gt;

&lt;p&gt;Power BI will display the PostgreSQL schemas and tables.&lt;/p&gt;

&lt;p&gt;Select the tables you need and click Load.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcrzvz6xdy5ebbouyuf76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcrzvz6xdy5ebbouyuf76.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first connection may take a little longer because Power BI is validating the SSL certificate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use DBeaver Before Power BI?
&lt;/h3&gt;

&lt;p&gt;Beginners often try to troubleshoot everything inside Power BI, which can be frustrating because the error messages are not always specific.&lt;/p&gt;

&lt;p&gt;DBeaver gives clearer feedback:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the host or port is wrong, DBeaver tells you immediately.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the password is incorrect, you'll see an authentication error.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the SSL certificate is missing or invalid, DBeaver points directly to the SSL problem.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once DBeaver connects successfully, Power BI usually becomes a straightforward configuration task.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Mistakes Beginners Run Into
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Using the wrong SQL Server instance name
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;localhost&lt;/code&gt; and &lt;code&gt;localhost\SQLEXPRESS&lt;/code&gt; are not the same thing. If one fails, check which instance is actually running. If &lt;code&gt;localhost&lt;/code&gt; is not working, use the localhost IP address &lt;code&gt;127.0.0.1&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Forgetting the port number for PostgreSQL
&lt;/h3&gt;

&lt;p&gt;Aiven does not always use the default PostgreSQL port &lt;code&gt;5432&lt;/code&gt;. Use the exact port shown in the Aiven dashboard.&lt;/p&gt;

&lt;h3&gt;
  
  
  Skipping SSL configuration
&lt;/h3&gt;

&lt;p&gt;Aiven requires encrypted connections. If you omit the certificate or use the wrong SSL mode, Power BI will refuse the connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mixing up authentication methods
&lt;/h3&gt;

&lt;p&gt;Local SQL Server often uses Windows authentication, while Aiven PostgreSQL uses database username and password authentication. Choosing the wrong method leads to login failures even when the credentials are correct.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaways
&lt;/h3&gt;

&lt;p&gt;By the end of this setup, you should be able to connect Power BI to two very different database environments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Local SQL Server using Windows or SQL authentication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Aiven PostgreSQL using SSL certificates and database credentials.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The local SQL Server connection is mostly about identifying the correct server instance. The Aiven PostgreSQL connection is mostly about getting SSL configured correctly. DBeaver acts as a useful checkpoint before you bring Power BI into the picture.&lt;/p&gt;

&lt;p&gt;Once both connections are working, the experience inside Power BI is surprisingly similar. You choose tables, load the data, and start building reports. The difficult part is usually the first successful connection. After that, adding new tables or refreshing data becomes much easier because the connection settings are already saved.&lt;/p&gt;

&lt;p&gt;If you're practicing, I recommend testing the local SQL Server connection first, then moving to Aiven PostgreSQL. It builds confidence because you learn the Power BI workflow before dealing with SSL and cloud networking details.&lt;/p&gt;

</description>
      <category>powerplatform</category>
      <category>sql</category>
      <category>postgres</category>
      <category>database</category>
    </item>
    <item>
      <title>Understanding Data Modeling, Schemas, Relationships, and Joins: A Beginner's Guide</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Sat, 11 Jul 2026 03:33:53 +0000</pubDate>
      <link>https://dev.to/okall_omondi/understanding-data-modeling-schemas-relationships-and-joins-a-beginners-guide-23k4</link>
      <guid>https://dev.to/okall_omondi/understanding-data-modeling-schemas-relationships-and-joins-a-beginners-guide-23k4</guid>
      <description>&lt;p&gt;When people first start learning SQL, they usually focus on writing queries. You learn &lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;WHERE&lt;/code&gt;, &lt;code&gt;GROUP BY&lt;/code&gt;, and maybe even a few aggregate functions. Everything seems manageable until you come across multiple tables. Suddenly, you're asking questions like:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why is the customer information in a different table? How are these tables connected? And what exactly is a JOIN?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you've been wondering the same thing, you're not alone.&lt;/p&gt;

&lt;p&gt;Before you can write meaningful SQL queries, you need to understand how data is organized. That's where data modeling, schemas, relationships, and joins come in. These concepts work together, and once they click, databases become much easier to understand.&lt;/p&gt;

&lt;p&gt;Let's go through them one step at a time.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Data Modeling?
&lt;/h2&gt;

&lt;p&gt;Think about building a house.&lt;/p&gt;

&lt;p&gt;Before anyone starts laying bricks, an architect creates a blueprint. The blueprint shows where the rooms go, how they're connected, and where everything belongs.&lt;/p&gt;

&lt;p&gt;Data modeling works the same way.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;data model&lt;/strong&gt; is the blueprint of a database. It defines what information needs to be stored, how it should be organized, and how different pieces of information relate to one another.&lt;/p&gt;

&lt;p&gt;Instead of rooms and doors, a data model deals with things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customers&lt;/li&gt;
&lt;li&gt;Products&lt;/li&gt;
&lt;li&gt;Orders&lt;/li&gt;
&lt;li&gt;Employees&lt;/li&gt;
&lt;li&gt;Payments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rather than storing everything in one giant table, the data model separates information into logical groups.&lt;/p&gt;

&lt;p&gt;For example, imagine you're designing a database for an online store.&lt;/p&gt;

&lt;p&gt;Instead of creating one huge table containing customer details, product information, payment records, and shipping addresses, you would divide the information into smaller tables.&lt;/p&gt;

&lt;p&gt;You might have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customers&lt;/li&gt;
&lt;li&gt;Products&lt;/li&gt;
&lt;li&gt;Orders&lt;/li&gt;
&lt;li&gt;Order Items&lt;/li&gt;
&lt;li&gt;Payments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each table has a clear purpose. This makes the database easier to maintain and reduces duplicate data.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a Schema?
&lt;/h2&gt;

&lt;p&gt;Once you've designed your data model, the next step is creating the actual structure inside the database.&lt;/p&gt;

&lt;p&gt;This structure is called a &lt;strong&gt;schema&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A schema describes how the database is organized. It contains the tables, columns, data types, constraints, and relationships.&lt;/p&gt;

&lt;p&gt;Think of it as the database's floor plan.&lt;/p&gt;

&lt;p&gt;For example, a &lt;strong&gt;Customers&lt;/strong&gt; table might look like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CustomerID&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Email&lt;/th&gt;
&lt;th&gt;Phone&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;Jane Doe&lt;/td&gt;
&lt;td&gt;[&lt;a href="mailto:jane@email.com"&gt;jane@email.com&lt;/a&gt;]&lt;/td&gt;
&lt;td&gt;555-1234&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The schema defines that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CustomerID&lt;/code&gt; is an integer.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Name&lt;/code&gt; is text.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Email&lt;/code&gt; stores email addresses.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Phone&lt;/code&gt; stores phone numbers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also specifies rules, such as requiring every customer to have a unique CustomerID.&lt;/p&gt;

&lt;p&gt;Without a schema, a database would have no structure. It would simply be a collection of unorganized data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding Primary Keys
&lt;/h2&gt;

&lt;p&gt;If every customer has a name, why can't we just use names to identify them?&lt;/p&gt;

&lt;p&gt;Because names aren't always unique.&lt;/p&gt;

&lt;p&gt;You might have two customers named John Kamau. Which one are you referring to?&lt;/p&gt;

&lt;p&gt;This is why databases use &lt;strong&gt;primary keys&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A primary key is a column whose value uniquely identifies every row in a table.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CustomerID&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;John Kamau&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;John Kamau&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The names are identical, but the CustomerIDs are different.&lt;/p&gt;

&lt;p&gt;This guarantees that every customer can always be identified correctly.&lt;/p&gt;

&lt;p&gt;A good primary key should:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never be empty&lt;/li&gt;
&lt;li&gt;Never contain duplicate values&lt;/li&gt;
&lt;li&gt;Stay stable over time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Almost every table in a relational database has one.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding Relationships Between Tables
&lt;/h2&gt;

&lt;p&gt;Databases become powerful because tables don't exist in isolation.&lt;/p&gt;

&lt;p&gt;They're connected through &lt;strong&gt;relationships&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A relationship tells the database how information in one table is connected to information in another.&lt;/p&gt;

&lt;p&gt;Imagine these two tables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Customers
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CustomerID&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;Musyoka&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;Kiilu&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Orders
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;OrderID&lt;/th&gt;
&lt;th&gt;CustomerID&lt;/th&gt;
&lt;th&gt;Total&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;5001&lt;/td&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5002&lt;/td&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;120&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5003&lt;/td&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;45&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice something?&lt;/p&gt;

&lt;p&gt;The Orders table contains CustomerID.&lt;/p&gt;

&lt;p&gt;That's not a coincidence.&lt;/p&gt;

&lt;p&gt;It links every order to the customer who placed it.&lt;/p&gt;

&lt;p&gt;CustomerID inside the Orders table is called a &lt;strong&gt;foreign key&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A foreign key points to the primary key in another table.&lt;/p&gt;

&lt;p&gt;This is how databases connect information without storing the same customer details repeatedly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Types of Relationships
&lt;/h2&gt;

&lt;p&gt;Most beginner databases use three types of relationships.&lt;/p&gt;

&lt;h3&gt;
  
  
  One-to-One
&lt;/h3&gt;

&lt;p&gt;One record matches exactly one record.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One employee has one company ID card.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These relationships are less common.&lt;/p&gt;




&lt;h3&gt;
  
  
  One-to-Many
&lt;/h3&gt;

&lt;p&gt;This is by far the most common relationship.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One customer places many orders.&lt;/li&gt;
&lt;li&gt;One teacher teaches many students.&lt;/li&gt;
&lt;li&gt;One department has many employees.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice that one side has a single record, while the other side can have many.&lt;/p&gt;




&lt;h3&gt;
  
  
  Many-to-Many
&lt;/h3&gt;

&lt;p&gt;Sometimes both sides can have multiple records.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Students enroll in many courses.&lt;/li&gt;
&lt;li&gt;Courses contain many students.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Databases usually solve this by introducing a third table called a &lt;strong&gt;junction table&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Students&lt;/li&gt;
&lt;li&gt;Courses&lt;/li&gt;
&lt;li&gt;StudentCourses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The StudentCourses table stores which student is enrolled in which course.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Are Joins?
&lt;/h2&gt;

&lt;p&gt;Now comes the question most beginners ask.&lt;/p&gt;

&lt;p&gt;If customer information is stored in one table and order information is stored in another, how do we view them together?&lt;/p&gt;

&lt;p&gt;The answer is &lt;strong&gt;JOINs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A JOIN combines rows from two or more tables based on a related column.&lt;/p&gt;

&lt;p&gt;Let's use the earlier example.&lt;/p&gt;

&lt;h3&gt;
  
  
  Customers
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CustomerID&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;Musyoka&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;Kiilu&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Orders
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;OrderID&lt;/th&gt;
&lt;th&gt;CustomerID&lt;/th&gt;
&lt;th&gt;Total&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;5001&lt;/td&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;75&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you write a JOIN, the result becomes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;OrderID&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Total&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;5001&lt;/td&gt;
&lt;td&gt;Musyoka&lt;/td&gt;
&lt;td&gt;75&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The database matches CustomerID in both tables and combines the related information.&lt;/p&gt;

&lt;p&gt;This is why relationships are so important. Without them, JOINs wouldn't know how the tables are connected.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Types of SQL Joins
&lt;/h2&gt;

&lt;p&gt;You'll encounter several types of joins as you learn SQL.&lt;/p&gt;

&lt;h3&gt;
  
  
  INNER JOIN
&lt;/h3&gt;

&lt;p&gt;Returns only matching records.&lt;/p&gt;

&lt;p&gt;If a customer has no orders, they won't appear in the results.&lt;/p&gt;

&lt;p&gt;This is the join you'll probably use most often.&lt;/p&gt;

&lt;h3&gt;
  
  
  LEFT JOIN
&lt;/h3&gt;

&lt;p&gt;Returns every record from the left table, even if there's no matching record in the right table.&lt;/p&gt;

&lt;p&gt;This is useful when you want to find customers who haven't placed any orders yet.&lt;/p&gt;

&lt;h3&gt;
  
  
  RIGHT JOIN
&lt;/h3&gt;

&lt;p&gt;Works like a LEFT JOIN but starts from the right table instead.&lt;/p&gt;

&lt;p&gt;Many SQL developers rarely use it because a LEFT JOIN can usually achieve the same result by switching the table order.&lt;/p&gt;

&lt;h3&gt;
  
  
  FULL OUTER JOIN
&lt;/h3&gt;

&lt;p&gt;Returns all records from both tables, matching where possible.&lt;/p&gt;

&lt;p&gt;If there's no match, the missing values are shown as &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Not every database system supports this join directly.&lt;/p&gt;




&lt;h2&gt;
  
  
  How These Concepts Fit Together
&lt;/h2&gt;

&lt;p&gt;It's easy to see these as separate topics, but they're really parts of the same picture.&lt;/p&gt;

&lt;p&gt;Here's the flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You create a &lt;strong&gt;data model&lt;/strong&gt; to plan your database.&lt;/li&gt;
&lt;li&gt;You implement that design using a &lt;strong&gt;schema&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Tables are connected through &lt;strong&gt;relationships&lt;/strong&gt; using primary and foreign keys.&lt;/li&gt;
&lt;li&gt;SQL &lt;strong&gt;JOINs&lt;/strong&gt; use those relationships to retrieve data from multiple tables.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you understand this sequence, writing SQL queries starts to make much more sense.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Beginner Mistakes
&lt;/h2&gt;

&lt;p&gt;Everyone makes mistakes while learning databases. Here are a few that come up often.&lt;/p&gt;

&lt;h3&gt;
  
  
  Putting everything into one table
&lt;/h3&gt;

&lt;p&gt;It may seem simpler at first, but it quickly leads to duplicated data and maintenance headaches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ignoring primary keys
&lt;/h3&gt;

&lt;p&gt;Without unique identifiers, it's difficult to connect tables correctly or guarantee data accuracy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Joining on the wrong columns
&lt;/h3&gt;

&lt;p&gt;Always check that you're joining a foreign key to its corresponding primary key. Joining unrelated columns can produce incorrect or misleading results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Memorizing joins without understanding relationships
&lt;/h3&gt;

&lt;p&gt;Many beginners try to memorize SQL syntax first. It's usually more effective to understand how the tables relate to one another. Once the relationships are clear, choosing the correct join becomes much easier.&lt;/p&gt;




&lt;h2&gt;
  
  
  Practical Tips for Learning
&lt;/h2&gt;

&lt;p&gt;If you're just getting started, don't rush into complex database designs.&lt;/p&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Draw your tables on paper before creating them.&lt;/li&gt;
&lt;li&gt;Label the primary and foreign keys.&lt;/li&gt;
&lt;li&gt;Practice identifying one-to-one, one-to-many, and many-to-many relationships.&lt;/li&gt;
&lt;li&gt;Build small databases, such as a library, school, or online store.&lt;/li&gt;
&lt;li&gt;Write simple JOIN queries and predict the results before running them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach helps you understand the logic behind the database rather than simply memorizing SQL syntax.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;data model&lt;/strong&gt; is the blueprint that plans how data should be organized.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;schema&lt;/strong&gt; defines the structure of the database, including tables and columns.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;primary key&lt;/strong&gt; uniquely identifies each record in a table.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;foreign key&lt;/strong&gt; connects one table to another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relationships&lt;/strong&gt; describe how tables are linked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JOINs&lt;/strong&gt; combine data from related tables to answer real-world questions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Data modeling, schemas, relationships, and joins can seem like separate topics when you're first learning databases. In reality, they're different pieces of the same foundation.&lt;/p&gt;

&lt;p&gt;Once you understand how data is organized and why tables are connected the way they are, SQL becomes far less intimidating. Queries stop feeling like random commands and start feeling like conversations with the database.&lt;/p&gt;

&lt;p&gt;If you're learning SQL, spend time understanding the structure before chasing more advanced syntax. A solid grasp of these fundamentals will make every future topic—from writing reports to designing databases—much easier to learn.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>powerplatform</category>
      <category>database</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How Excel is Used in Real-World Data Analysis</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Sat, 06 Jun 2026 06:35:07 +0000</pubDate>
      <link>https://dev.to/okall_omondi/how-excel-is-used-in-real-world-data-analysis-17hl</link>
      <guid>https://dev.to/okall_omondi/how-excel-is-used-in-real-world-data-analysis-17hl</guid>
      <description>&lt;h2&gt;
  
  
  What is Excel?
&lt;/h2&gt;

&lt;p&gt;Well, the simplest answer? Excel is a tool. &lt;br&gt;
You might ask, which tool? &lt;br&gt;
Think of it as a bookshelf, or the wardrobe in your house. &lt;br&gt;
What does the bookshelf and the wardrobe have in common? Partitions. &lt;br&gt;
Most bookshelves have identifiers to help you locate the exact partition where the book is stored. The last library I visited had letters and numbers. The letters were written horizontally (from left to right) across the bookshelf and the numbers were written vertically (from top to bottom). I could easily identify the exact partition by using the letter and number combination, for example the first partition in the bookshelf was A1. This is the exact way Excel is organized with letters and numbers. &lt;/p&gt;

&lt;p&gt;The partition A1 in the bookshelf represents &lt;strong&gt;a cell&lt;/strong&gt; in Excel. The horizontal letters (from left to right) of the bookshelf represent &lt;strong&gt;a row&lt;/strong&gt; in an Excel, and the vertical numbers from top to bottom in a bookshelf represent &lt;strong&gt;a column&lt;/strong&gt; in an Excel. A single bookshelf represents &lt;strong&gt;a worksheet&lt;/strong&gt; in Excel and several bookshelves represent &lt;strong&gt;a workbook&lt;/strong&gt; in Excel. Simple right?&lt;/p&gt;

&lt;h2&gt;
  
  
  How Excel is used in real world Data Analysis.
&lt;/h2&gt;

&lt;p&gt;You have probably heard of the phrase “data is the new oil” right? What makes it the new oil? Apart from it being the new “money printer”, data is the “know it all”, it is the real story teller. However, before data can tell you stories and turn into your cash machine, you must first make sense of it, to understand what happened and why it happened. The process of understanding what happened and why it happened is called Data Analysis. By understanding what happened and why it happened, you can easily figure out what will happen (Data Science). Excel is fundamental in the understanding phase, and in the figuring out phase, because it acts as the story for the data to be understood and figured out.&lt;/p&gt;

&lt;p&gt;Which areas do we then use Excel in the real world? Imagine this scenario, you are running a small refurbished laptops resale shop, every laptop you sell with a small profit on top of the purchase price, and making profits in your head. However, at the end of the month you find out you are short of cash to pay bills forcing you to borrow money from friends, yet, you did not sell any laptop at a loss. What do you do? This is where Excel comes in. Excel can help you to store your sales data, organize the data and clean the data. Excel also gives you formulas such as &lt;code&gt;SUM, AVERAGE, MIN, MAX, COUNT&lt;/code&gt; and functions such as &lt;code&gt;IF, SUMIF, AVERAGEIFS, VLOOKUP&lt;/code&gt; which you can use to do calculations and create logics to see how your business is doing. Excel also has pivot table functionality which is helpful in summarizing data quickly. You can also draw insights from the data using the various visualization tools in Excel such as charts and graphs to help you see where you are losing money and make informed decisions. &lt;/p&gt;

&lt;h2&gt;
  
  
  How has learning Excel changed how I see data?
&lt;/h2&gt;

&lt;p&gt;Learning Excel and understanding its capabilities has been an eye opener, and I now view every instance of my life as a data point to be tracked and understood. This past week I have started tracking simple things in my life like the time I go to bed, the time I wake up, how long I take on a task, and so much more. I will be using this data to improve and be a better person.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>datascience</category>
      <category>excel</category>
      <category>dataanalysis</category>
    </item>
    <item>
      <title>Diving into Bug Bounty Hunting: My Journey Begins with Resources and Tips for Beginners</title>
      <dc:creator>Okall Omondi</dc:creator>
      <pubDate>Mon, 20 Jan 2025 07:31:54 +0000</pubDate>
      <link>https://dev.to/okall_omondi/diving-into-bug-bounty-hunting-my-journey-begins-with-resources-and-tips-for-beginners-ggg</link>
      <guid>https://dev.to/okall_omondi/diving-into-bug-bounty-hunting-my-journey-begins-with-resources-and-tips-for-beginners-ggg</guid>
      <description>&lt;p&gt;After taking the much needed break and rest in the festive seasons, a period in which I had much reflection on my career and life goals, I dove into &lt;strong&gt;cybersecurity&lt;/strong&gt; with a focus on bug bounty hunting. I have been contemplating on this for a while, ever since I came across the 0 to 100K in Bug Bounty Year One thread on X by &lt;a href="https://x.com/Rhynorater" rel="noopener noreferrer"&gt;@Rhynorater&lt;/a&gt;. I used ChatGPT to create a bug bounty hunting road map and begun on a resource finding mission. I will write weekly posts documenting my journey and milestones into becoming a bug bounty hunter. This first article will document some of the useful resources that those aspiring to become bounty hunters can use. The resources range from ChatGPT, YouTube Channels, websites, GitHub Accounts, X Accounts, and SubReddits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remember
&lt;/h3&gt;

&lt;p&gt;When starting out, always be aware of the shiny object syndrome and analysis paralysis. Shiny object syndrome (SOS) is the tendency to be distracted by new ideas (courses) that are often at the expense of your current goal, which is becoming a bug bounty hunter in this case. Analysis paralysis is that point when you cannot decide because you are overwhelmed with courses/ materials and you are not sure of which one to use. &lt;/p&gt;

&lt;p&gt;Another thing I will recommend while starting is developing a good note taking system. There are various Note Taking Apps you can use, such as Notion, Evernote, Microsoft OneNote, Joplin, Obsidian and many others. When choosing a note app, there are factors you have to put into consideration. Some features I look for in a note taking app are cost, ease of use, organizational features, and cross device access. My choice is &lt;a href="https://obsidian.md/" rel="noopener noreferrer"&gt;Obsidian&lt;/a&gt;. Having a good note taking system is like having a second brain. Good notes always come in handy along your career trajectory, and they are what will catapult you to the next level.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;Now, back to resources. I will focus on the free resources here, as I believe most of the required knowledge is free if you have the patience and time to go after it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ChatGPT:&lt;/strong&gt; The first and key resource I found helpful is ChatGPT. You are not restricted to this. You can use GPTs of your choice like copilot, Gemini or any other you may prefer. I used ChatGPT to brainstorm and be sure that I really wanted to go into bug bounty hunting. After being sure I wanted this, I prompted it to come up with a learning path and a study plan for bug bounty hunting. There are unlimited ways you can use GPTs from generating explanations, examples and analogies, motivation, role-plays, questions, mind maps, mental associations and much more. You can also use them to engineer effective prompts which you can then re-use to get exact answers you want. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;YouTube Channels:&lt;/strong&gt; Some of the YouTube channels I have found to be amazing are: &lt;br&gt;
&lt;a href="https://www.youtube.com/@NahamSec" rel="noopener noreferrer"&gt;NahamSec&lt;/a&gt; - Has detailed bug bounty tutorials and live hacking sessions.&lt;br&gt;
&lt;a href="https://www.youtube.com/@STOKfredrik" rel="noopener noreferrer"&gt;STÖK&lt;/a&gt; - Offers practical bug hunting techniques and methodologies.&lt;br&gt;
&lt;a href="https://www.youtube.com/@InsiderPhD" rel="noopener noreferrer"&gt;InsiderPhD&lt;/a&gt; - Insider PHD is great for beginners, provides structured learning content. This is the channel I have been using, mostly. I highly recommend it if you are starting out.&lt;br&gt;
&lt;a href="https://www.youtube.com/@jhaddix" rel="noopener noreferrer"&gt;Jason Haddix&lt;/a&gt; - Industry veteran sharing advanced techniques and methodologies&lt;br&gt;
&lt;a href="https://www.youtube.com/@TCMSecurityAcademy" rel="noopener noreferrer"&gt;TCM Security&lt;/a&gt; - Comprehensive ethical hacking and penetration testing tutorials&lt;br&gt;
&lt;a href="https://www.youtube.com/@HackerSploit" rel="noopener noreferrer"&gt;HackerSploit&lt;/a&gt; - Detailed tutorials on various security tools and techniques&lt;br&gt;
&lt;a href="https://www.youtube.com/@LiveOverflow" rel="noopener noreferrer"&gt;LiveOverflow&lt;/a&gt; - In-depth technical content about security research and exploitation&lt;br&gt;
&lt;a href="https://www.youtube.com/@portswigger" rel="noopener noreferrer"&gt;PortSwigger&lt;/a&gt; - Official channel for Burp Suite with web security tutorials&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Learning Websites:&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://portswigger.net/web-security" rel="noopener noreferrer"&gt;PortSwigger Web Security Academy&lt;/a&gt; - Free, comprehensive web security training. I recommend PortSwigger Academy if you are starting out.&lt;br&gt;
&lt;a href="https://www.bugcrowd.com/hackers/bugcrowd-university" rel="noopener noreferrer"&gt;Bugcrowd University&lt;/a&gt; - Free educational resources for bug bounty hunters. Bugcrowd also provides a platform for the Vulnerability Disclosure Program (VDP) and Bug Bounty Programs (BBP). It is a good place to start your bug bounty hunting by creating an account on their platform.&lt;br&gt;
&lt;a href="https://www.tryhackme.com/" rel="noopener noreferrer"&gt;TryHackMe&lt;/a&gt; - Interactive cybersecurity training platform with guided learning paths. Try Hack Me is fully free, but it has some amazing labs that provide hands-on experience.&lt;br&gt;
&lt;a href="https://www.hackthebox.com/" rel="noopener noreferrer"&gt;HackTheBox&lt;/a&gt; - Platform offering realistic penetration testing labs and challenges&lt;br&gt;
&lt;a href="https://www.hackerone.com/hacktivity" rel="noopener noreferrer"&gt;HackerOne Hacktivity&lt;/a&gt; - Public bug reports to learn from real-world examples. HackerOne also provides a platform for the Vulnerability Disclosure Program (VDP) and Bug Bounty Programs (BBP).&lt;br&gt;
&lt;a href="https://pentesterlab.com" rel="noopener noreferrer"&gt;PentesterLab&lt;/a&gt; - Hands-on exercises for web penetration testing&lt;br&gt;
&lt;a href="https://www.vulnhub.com" rel="noopener noreferrer"&gt;VulnHub&lt;/a&gt; - Provides materials to gain practical cybersecurity experience&lt;br&gt;
&lt;a href="https://owasp.org" rel="noopener noreferrer"&gt;OWASP&lt;/a&gt; - Comprehensive resource for web application security knowledge&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GitHub Accounts:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/m0chan/BugBounty/tree/master" rel="noopener noreferrer"&gt;BugBounty&lt;/a&gt;: This GitHub account has most of the resources you need in becoming a bounty hunter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;X Accounts:&lt;/strong&gt; There is an amazing Bug Bounty Community on X with lots of accounts dedicated to sharing information on Bug Bounty Hunting. I will not recommend any account in particular but if you are on X, search for a bug bounty and you’ll find lots of accounts with posts that will inspire you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SubReddits:&lt;/strong&gt; Reddit is another Social Media platform I like. There is an amazing community here with amazing people who are always ready to jump in and assist with any query you might be having. Just be sure to search first if the question was asked and answered before. Also, be sure to ask on the right subreddit. The subreddit for bug bounty hunters which is active, and I’d recommend you join is &lt;a href="https://www.reddit.com/r/bugbounty/" rel="noopener noreferrer"&gt;r/bugbounty/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>security</category>
      <category>beginners</category>
      <category>career</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
