<?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: Victor Karanja</title>
    <description>The latest articles on DEV Community by Victor Karanja (@victak36lgtm).</description>
    <link>https://dev.to/victak36lgtm</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%2F3708651%2Fd2e66539-b7bd-4a09-b578-106fcec24dea.jpeg</url>
      <title>DEV Community: Victor Karanja</title>
      <link>https://dev.to/victak36lgtm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/victak36lgtm"/>
    <language>en</language>
    <item>
      <title>Python for Beginners (Part 2): Mastering Python Fundamentals</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Mon, 27 Jul 2026 06:30:16 +0000</pubDate>
      <link>https://dev.to/victak36lgtm/python-for-beginners-part-2-mastering-python-fundamentals-4i6n</link>
      <guid>https://dev.to/victak36lgtm/python-for-beginners-part-2-mastering-python-fundamentals-4i6n</guid>
      <description>&lt;p&gt;Welcome back!&lt;br&gt;&lt;br&gt;
In Part 1 we learned variables and how to print information. Now it’s time to make our programs smarter and more useful.&lt;/p&gt;

&lt;p&gt;In this part you will learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comparison operators
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;elif&lt;/code&gt;, and &lt;code&gt;else&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;for&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; loops
&lt;/li&gt;
&lt;li&gt;Functions
&lt;/li&gt;
&lt;li&gt;Lists
&lt;/li&gt;
&lt;li&gt;Dictionaries
&lt;/li&gt;
&lt;li&gt;A complete Student Grade Calculator project
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s get started.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Comparison Operators
&lt;/h3&gt;

&lt;p&gt;Comparison operators check the relationship between two values and return &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&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;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&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;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# True  (greater than)
&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;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# False (less than)
&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;x&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# False (equal to)
&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;x&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# True  (not equal to)
&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;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# True  (greater than or equal)
&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;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# False (less than or equal)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These operators are the foundation of decision-making in Python.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. if, elif, and else
&lt;/h3&gt;

&lt;p&gt;These statements let your program choose different actions based on conditions.&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;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;70&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 C&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;Grade D&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;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;if&lt;/code&gt; checks the first condition&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;elif&lt;/code&gt; checks the next condition only if the previous ones were False&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;else&lt;/code&gt; runs when none of the conditions are True&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Always remember to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Put a colon &lt;code&gt;:&lt;/code&gt; at the end of each condition&lt;/li&gt;
&lt;li&gt;Indent the code under each block (4 spaces)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. for and while Loops
&lt;/h3&gt;

&lt;p&gt;Loops allow you to repeat code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;for loop&lt;/strong&gt; – best when you know how many times to repeat:&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;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="mi"&gt;5&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;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0
1
2
3
4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;while loop&lt;/strong&gt; – best when you want to keep repeating as long as a condition is True:&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;count&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;while&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&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;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;count&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;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0
1
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Extra tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;break&lt;/code&gt; → stop the loop immediately&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;continue&lt;/code&gt; → skip the rest of the current loop and move to the next one&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Functions
&lt;/h3&gt;

&lt;p&gt;Functions help you write reusable code. You define it once and use it many times.&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;greet&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello,&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="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;greet&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&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sam&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;You can also return a 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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# 15
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Lists
&lt;/h3&gt;

&lt;p&gt;A list stores multiple items in a specific order.&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;fruits&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;apple&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;banana&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;orange&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="n"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;          &lt;span class="c1"&gt;# apple
&lt;/span&gt;&lt;span class="n"&gt;fruits&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;mango&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# add a new item
&lt;/span&gt;&lt;span class="nf"&gt;print&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;fruits&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;        &lt;span class="c1"&gt;# 4
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also loop through a list:&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;for&lt;/span&gt; &lt;span class="n"&gt;fruit&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fruits&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;fruit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Dictionaries
&lt;/h3&gt;

&lt;p&gt;A dictionary stores data as key-value pairs.&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;student&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;name&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&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;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&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&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;B&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="n"&gt;student&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&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;     &lt;span class="c1"&gt;# Alex
&lt;/span&gt;&lt;span class="n"&gt;student&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&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;     &lt;span class="c1"&gt;# update a value
&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;student&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Mini Project: Student Grade Calculator
&lt;/h3&gt;

&lt;p&gt;Now let’s combine everything we learned into a small real project.&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;calculate_grade&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&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;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="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A&lt;/span&gt;&lt;span class="sh"&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="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;B&lt;/span&gt;&lt;span class="sh"&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;70&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;C&lt;/span&gt;&lt;span class="sh"&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;60&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;D&lt;/span&gt;&lt;span class="sh"&gt;"&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;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;F&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# List of students (each student is a dictionary)
&lt;/span&gt;&lt;span class="n"&gt;students&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;name&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&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;score&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;92&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;name&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;Sam&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;score&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;78&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;name&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;Jordan&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;score&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;65&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;name&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;Taylor&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;score&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="p"&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;Student Grade Report&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="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;student&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_grade&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;score&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="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;student&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&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&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;student&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; → Grade &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;grade&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;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Student Grade Report
-------------------
Alex: 92 → Grade A
Sam: 78 → Grade C
Jordan: 65 → Grade D
Taylor: 55 → Grade F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What You Learned Today
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;How to compare values
&lt;/li&gt;
&lt;li&gt;How to make decisions with &lt;code&gt;if / elif / else&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;How to repeat actions with loops
&lt;/li&gt;
&lt;li&gt;How to create reusable functions
&lt;/li&gt;
&lt;li&gt;How to store data with lists and dictionaries
&lt;/li&gt;
&lt;li&gt;How to build a complete mini project
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Great work!&lt;br&gt;&lt;br&gt;
Try changing the scores or adding more students to practice. The more you experiment, the faster you will improve.&lt;/p&gt;

&lt;p&gt;See you in the next part!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python for Beginners (Part 1): From Zero to Writing Your First Programs</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Mon, 27 Jul 2026 06:21:00 +0000</pubDate>
      <link>https://dev.to/victak36lgtm/python-for-beginners-part-1-from-zero-to-writing-your-first-programs-2ahk</link>
      <guid>https://dev.to/victak36lgtm/python-for-beginners-part-1-from-zero-to-writing-your-first-programs-2ahk</guid>
      <description>&lt;h1&gt;
  
  
  Python for Beginners (Part 1): From Zero to Writing Your First Programs
&lt;/h1&gt;

&lt;p&gt;Python is one of the most beginner-friendly programming languages in the world. Whether you want to become a data analyst, data scientist, backend developer, automation engineer, or AI engineer, Python is an excellent place to start.&lt;/p&gt;

&lt;p&gt;In this first part of the series, you'll learn the fundamentals you need before moving on to decision-making, loops, and functions in Part 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Learn Python?
&lt;/h2&gt;

&lt;p&gt;Python is known for its simple syntax, making it easy to read and write. It is used in many fields, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data Analysis&lt;/li&gt;
&lt;li&gt;Artificial Intelligence and Machine Learning&lt;/li&gt;
&lt;li&gt;Web Development&lt;/li&gt;
&lt;li&gt;Automation&lt;/li&gt;
&lt;li&gt;Cybersecurity&lt;/li&gt;
&lt;li&gt;Scientific Computing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've never written code before, don't worry. We'll take it one step at a time.&lt;/p&gt;




&lt;h1&gt;
  
  
  Installing Python
&lt;/h1&gt;

&lt;p&gt;Download the latest version of Python from the official website.&lt;/p&gt;

&lt;p&gt;During installation on Windows, remember to check &lt;strong&gt;"Add Python to PATH"&lt;/strong&gt; before clicking &lt;strong&gt;Install Now&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To verify your installation, open a terminal and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If Python is installed correctly, you'll see the installed version number.&lt;/p&gt;




&lt;h1&gt;
  
  
  Writing Your First Program
&lt;/h1&gt;

&lt;p&gt;Let's start with the classic program.&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;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, World!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations! You've written your first Python program.&lt;/p&gt;




&lt;h1&gt;
  
  
  Variables
&lt;/h1&gt;

&lt;p&gt;Variables store information that your program can use later.&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="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="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;
&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.68&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can display them using &lt;code&gt;print()&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="nf"&gt;print&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="n"&gt;age&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;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Common Data Types
&lt;/h1&gt;

&lt;p&gt;Python has several built-in data types.&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="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="c1"&gt;# String
&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;22&lt;/span&gt;            &lt;span class="c1"&gt;# Integer
&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.68&lt;/span&gt;       &lt;span class="c1"&gt;# Float
&lt;/span&gt;&lt;span class="n"&gt;is_student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;   &lt;span class="c1"&gt;# Boolean
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understanding data types helps you write reliable programs and avoid common mistakes.&lt;/p&gt;




&lt;h1&gt;
  
  
  Getting User Input
&lt;/h1&gt;

&lt;p&gt;Programs become more useful when they interact with users.&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;Enter 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;Hello,&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="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Enter your name: Victor
Hello, Victor
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Basic Operators
&lt;/h1&gt;

&lt;p&gt;Python supports arithmetic operators.&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;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&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;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&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;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&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;a&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;b&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;a&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also calculate remainders using &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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Writing Comments
&lt;/h1&gt;

&lt;p&gt;Comments explain your code and are ignored by 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="c1"&gt;# This is a comment
&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;Alice&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Comments make your code easier for you and others to understand.
&lt;/h2&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;By completing this article, you've learned how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Python&lt;/li&gt;
&lt;li&gt;Write your first program&lt;/li&gt;
&lt;li&gt;Create variables&lt;/li&gt;
&lt;li&gt;Work with common data types&lt;/li&gt;
&lt;li&gt;Accept user input&lt;/li&gt;
&lt;li&gt;Perform basic calculations&lt;/li&gt;
&lt;li&gt;Write comments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the building blocks you'll use in almost every Python program.&lt;/p&gt;




&lt;h1&gt;
  
  
  What's Next?
&lt;/h1&gt;

&lt;p&gt;In &lt;strong&gt;Part 2&lt;/strong&gt;, we'll make our programs smarter by learning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comparison operators&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;elif&lt;/code&gt;, and &lt;code&gt;else&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;for&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; loops&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Lists&lt;/li&gt;
&lt;li&gt;Dictionaries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy coding, and see you in Part 2!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/victak36lgtm/python-for-beginners-part-2-mastering-python-fundamentals-4i6n"&gt;https://dev.to/victak36lgtm/python-for-beginners-part-2-mastering-python-fundamentals-4i6n&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Importance of Hypothesis Testing in Data Science</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Mon, 27 Jul 2026 05:47:03 +0000</pubDate>
      <link>https://dev.to/victak36lgtm/importance-of-hypothesis-testing-in-data-science-2ppn</link>
      <guid>https://dev.to/victak36lgtm/importance-of-hypothesis-testing-in-data-science-2ppn</guid>
      <description>&lt;p&gt;A hypothesis is a clear, testable statement about a population or process. Hypothesis testing then uses sample data to decide whether there is enough evidence to support or reject that statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hypothesis Testing: The Statistical Compass of Data Science&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Collecting data and training models are only part of the story. The real power of data science emerges when numbers are turned into decisions that can be trusted. Hypothesis testing is the method that makes those decisions rigorous rather than guesswork.&lt;/p&gt;

&lt;p&gt;It gives analysts a structured way to ask: “Is the pattern I see strong enough that random chance is an unlikely explanation?” Whether the question involves customer behavior, medical outcomes, marketing results, or operational improvements, the same disciplined process applies. Without it, conclusions rest on visual impressions or gut feeling. With it, they rest on quantified evidence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defining the Framework
&lt;/h3&gt;

&lt;p&gt;Hypothesis testing evaluates whether sample evidence supports a claim about a larger population. It begins with two carefully worded statements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;null hypothesis (H₀)&lt;/strong&gt; represents the status quo—no difference, no effect, no relationship.
&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;alternative hypothesis (H₁)&lt;/strong&gt; expresses the claim the analyst wants to investigate.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A p-value measures how surprising the observed data would be if the null were true. When that probability falls below a chosen threshold (usually 0.05), the null is rejected. When it does not, the analyst simply fails to reject the null—an important distinction from “proving” it true.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practical Value for Data Teams
&lt;/h3&gt;

&lt;p&gt;The method delivers several concrete benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It separates genuine signals from noise.
&lt;/li&gt;
&lt;li&gt;It supplies a shared language of uncertainty for stakeholders.
&lt;/li&gt;
&lt;li&gt;It allows fair comparison of algorithms, treatments, or customer groups.
&lt;/li&gt;
&lt;li&gt;It turns vague observations (“sales seem higher”) into precise statements backed by probability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, it elevates analysis from description to inference.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Clear Workflow
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Translate the business question into explicit null and alternative hypotheses.
&lt;/li&gt;
&lt;li&gt;Select the significance level and the test that matches the data structure and assumptions.
&lt;/li&gt;
&lt;li&gt;Calculate the test statistic and p-value.
&lt;/li&gt;
&lt;li&gt;Interpret the result in context, ideally reporting effect size and confidence intervals alongside the p-value.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Main Families of Tests
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;t-Tests&lt;/strong&gt; remain the most frequently used tools for continuous outcomes.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One-sample versions check a sample mean against a known benchmark.
&lt;/li&gt;
&lt;li&gt;Independent two-sample versions compare two separate groups (classic A/B tests).
&lt;/li&gt;
&lt;li&gt;Paired versions examine the same units before and after a change.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When data are roughly normal and groups are independent, these tests are efficient and easy to communicate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Z-tests&lt;/strong&gt; serve a narrower role—large samples with known population variance—yet still appear in large-scale proportion testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chi-square procedures&lt;/strong&gt; handle categorical variables. The test of independence asks whether two factors are associated; the goodness-of-fit test checks whether observed frequencies match expected proportions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ANOVA&lt;/strong&gt; extends the comparison of means to three or more groups. One-way ANOVA is the standard starting point; two-way versions add a second factor. When normality or equal-variance assumptions fail, the Kruskal-Wallis rank test provides a robust alternative.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-parametric rank tests&lt;/strong&gt; fill the gaps left by parametric methods:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mann-Whitney U for two independent groups with skewed or ordinal data,
&lt;/li&gt;
&lt;li&gt;Wilcoxon signed-rank for paired non-normal differences,
&lt;/li&gt;
&lt;li&gt;Kruskal-Wallis for multiple groups under the same conditions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Quick Selection Guide
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;Preferred approach&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Single mean vs. fixed value&lt;/td&gt;
&lt;td&gt;One-sample t-test&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Two independent groups, normal data&lt;/td&gt;
&lt;td&gt;Independent or Welch t-test&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Two independent groups, non-normal data&lt;/td&gt;
&lt;td&gt;Mann-Whitney U&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Matched pairs, normal differences&lt;/td&gt;
&lt;td&gt;Paired t-test&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Matched pairs, non-normal differences&lt;/td&gt;
&lt;td&gt;Wilcoxon signed-rank&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Three or more groups, normal data&lt;/td&gt;
&lt;td&gt;One-way ANOVA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Three or more groups, non-normal data&lt;/td&gt;
&lt;td&gt;Kruskal-Wallis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relationship between categories&lt;/td&gt;
&lt;td&gt;Chi-square independence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Observed vs. theoretical frequencies&lt;/td&gt;
&lt;td&gt;Chi-square goodness-of-fit&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Everyday Applications and Caveats
&lt;/h3&gt;

&lt;p&gt;In day-to-day work these tests support A/B experimentation, model comparison, feature screening, process monitoring, and quasi-experimental evaluation. They appear both in formal research and in rapid business experiments.&lt;/p&gt;

&lt;p&gt;Experienced practitioners treat p-values as only one piece of evidence. Practical importance (effect size), multiple-testing corrections, and assumption checks are equally essential. Large samples can make tiny differences statistically significant; domain knowledge must still decide whether those differences matter.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Perspective
&lt;/h3&gt;

&lt;p&gt;Hypothesis testing is the quiet discipline that keeps data science accountable. It forces clear claims, quantifies uncertainty, and protects teams from mistaking noise for insight. When used thoughtfully—paired with effect sizes, diagnostics, and subject-matter judgment—it becomes one of the most reliable tools for turning data into decisions that stand up to scrutiny.&lt;/p&gt;

</description>
      <category>analysis</category>
      <category>data</category>
      <category>datascience</category>
      <category>science</category>
    </item>
    <item>
      <title>Understanding SQL: DDL, DML, and Data Transformation</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Fri, 24 Apr 2026 04:59:22 +0000</pubDate>
      <link>https://dev.to/victak36lgtm/-understanding-sql-ddl-dml-and-data-transformation-3hkh</link>
      <guid>https://dev.to/victak36lgtm/-understanding-sql-ddl-dml-and-data-transformation-3hkh</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Structured Query Language (SQL) is the standard language for managing and manipulating relational databases.&lt;/p&gt;

&lt;p&gt;This article explores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data Definition Language (DDL)&lt;/li&gt;
&lt;li&gt;Data Manipulation Language (DML)&lt;/li&gt;
&lt;li&gt;Filtering with WHERE&lt;/li&gt;
&lt;li&gt;Conditional logic using CASE WHEN&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Are DDL and DML?
&lt;/h2&gt;

&lt;p&gt;SQL commands are broadly categorized into two groups: &lt;strong&gt;DDL&lt;/strong&gt; and &lt;strong&gt;DML&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Definition Language (DDL)
&lt;/h3&gt;

&lt;p&gt;DDL commands define and modify the &lt;strong&gt;structure&lt;/strong&gt; of database objects. They shape of your database—creating tables, altering columns, and removing schemas. DDL operations take effect immediately and permanently.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CREATE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Build new database objects (schemas, tables, columns)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ALTER&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Modify existing structures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DROP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Delete objects entirely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;RENAME&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Change object names&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Data Manipulation Language (DML)
&lt;/h3&gt;

&lt;p&gt;DML commands manage the &lt;strong&gt;data inside&lt;/strong&gt; tables, adding rows, updating values, and deleting records. Unlike DDL, DML changes can be rolled back using transactions if something goes wrong.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;INSERT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Add new rows to a table&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;UPDATE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Modify existing data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DELETE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Remove specific rows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SELECT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieve data (sometimes classified as DQL)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The Key Difference
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;DDL&lt;/th&gt;
&lt;th&gt;DML&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Focus&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Structure&lt;/td&gt;
&lt;td&gt;Data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Commands&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;ALTER&lt;/code&gt;, &lt;code&gt;DROP&lt;/code&gt;, &lt;code&gt;RENAME&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;INSERT&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;, &lt;code&gt;SELECT&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Reversibility&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Permanent (auto-commit)&lt;/td&gt;
&lt;td&gt;Can be rolled back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Adding a new column&lt;/td&gt;
&lt;td&gt;Changing a student's grade&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  DDL in Action: Building the Nairobi Academy Database
&lt;/h2&gt;

&lt;p&gt;In the Nairobi Academy assignment, DDL commands established the entire database framework from scratch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the Schema and Tables
&lt;/h3&gt;

&lt;p&gt;The first step was creating a dedicated schema to organize all school-related tables:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
sql
CREATE SCHEMA nairobi_academy;
SET search_path TO nairobi_academy;
Then three tables were built using CREATE TABLE:
sql
-- Students table stores pupil information
CREATE TABLE students (
    student_id SERIAL PRIMARY KEY,
    first_name VARCHAR(50) NOT NULL,
    last_name VARCHAR(50) NOT NULL,
    gender CHAR(1) CHECK (gender IN ('M', 'F')),
    class VARCHAR(20),
    city VARCHAR(50),
    date_of_birth DATE
);

-- Subjects table stores courses offered
CREATE TABLE subjects (
    subject_id SERIAL PRIMARY KEY,
    subject_name VARCHAR(100) NOT NULL,
    department VARCHAR(50),
    credits INTEGER
);

-- Exam_results links students to their scores
CREATE TABLE exam_results (
    result_id SERIAL PRIMARY KEY,
    student_id INTEGER REFERENCES students(student_id),
    subject_id INTEGER REFERENCES subjects(subject_id),
    marks INTEGER CHECK (marks &amp;gt;= 0 AND marks &amp;lt;= 100),
    exam_date DATE
);
Modifying Structure with ALTER
Real-world databases evolve. When the school forgot to include phone numbers, ALTER TABLE resolved it:
sql
Copy
ALTER TABLE students ADD COLUMN phone_number VARCHAR(20);
Later, the credits column needed clearer naming:
sql

ALTER TABLE subjects RENAME COLUMN credits TO credit_hours;
When the requirement changed again, the column was removed:
sql

ALTER TABLE students DROP COLUMN phone_number;
These ALTER operations demonstrate DDL's flexibility—structures adapt without rebuilding everything.
DML in Action: Populating and Managing Data
Once tables existed, DML commands brought them to life with real student records.
INSERT: Adding Data
Ten students, ten subjects, and ten exam results were inserted:
sql

INSERT INTO students (first_name, last_name, gender, class, city, date_of_birth) 
VALUES ('James', 'Mwangi', 'M', 'Form 4', 'Nairobi', '2006-03-15');
The INSERT statement follows a clear pattern: specify the table, list columns, then provide values in matching order. Bulk inserts use comma-separated value sets.
UPDATE: Correcting Data
When Esther Akinyi moved from Nakuru to Nairobi, UPDATE reflected this change:

sql
UPDATE students 
SET city = 'Nairobi' 
WHERE student_id = 5;
A marks entry error was also fixed:

sql

UPDATE exam_results 
SET marks = 59 
WHERE result_id = 5;
Critical rule: Always use WHERE with UPDATE. Without it, every row changes.
DELETE: Removing Data
When an exam was cancelled, DELETE removed it cleanly:
sql

DELETE FROM exam_results 
WHERE result_id = 9;
Again, WHERE is essential—omitting it empties the entire table.
Filtering Data with WHERE
The WHERE clause is SQL's gatekeeper. It filters rows based on conditions, ensuring queries return only relevant data.
Basic Comparison Operators
Table
Operator    Meaning Example
=   Equal to    WHERE class = 'Form 4'
&amp;gt;   Greater than    WHERE marks &amp;gt; 70
&amp;lt;   Less than   WHERE marks &amp;lt; 40
&amp;gt;=  Greater than or equal   WHERE marks &amp;gt;= 70
&amp;lt;=  Less than or equal  WHERE marks &amp;lt;= 50
&amp;lt;&amp;gt; or !=    Not equal   WHERE city &amp;lt;&amp;gt; 'Nairobi'
Logical Operators
Combine conditions with AND and OR:

sql
-- Form 3 students from Nairobi (both conditions must be true)
SELECT * FROM students WHERE class = 'Form 3' AND city = 'Nairobi';

-- Students in Form 2 or Form 4 (either condition can be true)
SELECT * FROM students WHERE class = 'Form 2' OR class = 'Form 4';
Special Operators
BETWEEN checks ranges inclusively:

sql
-- Marks from 50 to 80, including both endpoints
SELECT * FROM exam_results WHERE marks BETWEEN 50 AND 80;
IN checks membership in a list:

sql

-- Students in any of these three cities
SELECT * FROM students WHERE city IN ('Nairobi', 'Mombasa', 'Kisumu');
N IN excludes values:

sql

-- Students in Form 1 or Form 4 only
SELECT * FROM students WHERE class NOT IN ('Form 2', 'Form 3');

LIKE enables pattern matching with wildcards:
Table
Pattern Matches
'A%'    Starts with 'A'
'%Studies%' Contains 'Studies' anywhere
'_a%'   Second letter is 'a'

sql

-- First names starting with A or E
SELECT * FROM students 
WHERE first_name LIKE 'A%' OR first_name LIKE 'E%';
Transforming Data with CASE WHEN
Raw data often needs interpretation before it becomes useful. CASE WHEN acts as SQL's if-then-else logic, creating new calculated columns based on conditions.
Grading Exam Results
Instead of displaying raw marks, the assignment labeled each score with a performance grade:
sql

SELECT 
    result_id,
    marks,
    CASE 
        WHEN marks &amp;gt;= 80 THEN 'Distinction'
        WHEN marks &amp;gt;= 60 THEN 'Merit'
        WHEN marks &amp;gt;= 40 THEN 'Pass'
        ELSE 'Fail'
    END AS performance
FROM exam_results;
SQL evaluates conditions top to bottom. A mark of 85 hits the first condition (&amp;gt;= 80) and becomes "Distinction"—it never reaches the &amp;gt;= 60 check. This ordering is crucial.
Categorizing Students
Students were grouped into academic levels:
sql

SELECT 
    first_name,
    last_name,
    class,
    CASE 
        WHEN class IN ('Form 3', 'Form 4') THEN 'Senior'
        WHEN class IN ('Form 1', 'Form 2') THEN 'Junior'
    END AS student level
FROM students;
Every CASE must end with END, and AS names the new column.    

Inconclusion, DDL builds the container, while DML fills and shapes the content. The Nairobi Academy data, demonstrated this relationship—CREATE and ALTER established tables, then INSERT, UPDATE, and DELETE managed student records. Filtering with WHERE and operators like BETWEEN, IN, and LIKE narrowed results to specific needs. Finally, CASE WHEN transformed numerical marks into meaningful categories, proving that SQL is not just about storing data—it's about making data understandable.
Mastering these basics prepares you for;
*joins
*windows functions
*Query optimization
*subqueries.
 In SQL real understanding comes from writing queries and lots of practice.


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

&lt;/div&gt;

</description>
      <category>beginners</category>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Unlocking Insights: Transforming Messy Data Into Action Using Power BI</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Mon, 09 Feb 2026 06:37:03 +0000</pubDate>
      <link>https://dev.to/victak36lgtm/unlocking-insights-transforming-messy-data-into-action-using-power-bi-3lnn</link>
      <guid>https://dev.to/victak36lgtm/unlocking-insights-transforming-messy-data-into-action-using-power-bi-3lnn</guid>
      <description>&lt;ol&gt;
&lt;li&gt;
## How Analysts Clean Messy Data, Use DAX, and Build Dashboards Using Power BI
Power BI is an intelligent tool that helps organizations visualize and analyze their data. Raw day-to-day data can be messy and unfiltered. Analysts often deal with missing values, inconsistent formats, duplicates, and poorly structured tables. Power BI stands out because it allows analysts to clean, model, analyze, and visualize data. This article explains how analysts transform messy data into meaningful insights.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cleaning Messy Data with Power Query
&lt;/h2&gt;

&lt;p&gt;After loading your dataset, open &lt;em&gt;transform data&lt;/em&gt; to access the Power Query Editor.&lt;/p&gt;

&lt;h3&gt;
  
  
  common data problems
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Duplicate records- Inconsistent text (e.g.  'cardiology' 'cardio dep' 'Cardiolgy')
&lt;/li&gt;
&lt;li&gt;Numbers stored as text
&lt;/li&gt;
&lt;li&gt;Multiple values in a single column
&lt;/li&gt;
&lt;li&gt;Inconsistent date form&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of the common Power query Transformation are:&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Data Problems
&lt;/h2&gt;

&lt;p&gt;Real-world datasets are rarely perfect. Analysts often encounter the following data issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing values (nulls or blanks)&lt;/li&gt;
&lt;li&gt;Duplicate records&lt;/li&gt;
&lt;li&gt;Inconsistent text values (cardiology, Cardiology, Cardiology dept)&lt;/li&gt;
&lt;li&gt;Incorrect data types (numbers stored as text)&lt;/li&gt;
&lt;li&gt;Inconsistent date formats&lt;/li&gt;
&lt;li&gt;Spelling errors and typos&lt;/li&gt;
&lt;li&gt;Extra spaces or hidden characters&lt;/li&gt;
&lt;li&gt;Multiple values stored in a single column&lt;/li&gt;
&lt;li&gt;Inconsistent units of measurement&lt;/li&gt;
&lt;li&gt;Outliers and extreme values&lt;/li&gt;
&lt;li&gt;Poorly structured tables&lt;/li&gt;
&lt;li&gt;Mismatched keys between tables&lt;/li&gt;
&lt;li&gt;Changing data definitions over time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Addressing these problems during data preparation ensures accurate analysis, reliable dashboards, and trustworthy business insights.&lt;/p&gt;

&lt;p&gt;Power Query automatically records every step, so you can modify your transformation at any time.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧩 Understanding Data Modelling in Power BI
&lt;/h2&gt;

&lt;p&gt;Before you start writing DAX, it’s important to understand data modelling. A data model is simply the way your tables connect inside Power BI. Think of it as the “map” that tells Power BI how your data fits together.&lt;/p&gt;

&lt;p&gt;A good data model usually includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fact tables&lt;/strong&gt; – contain numbers you want to analyze (sales, revenue, quantities).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dimension tables&lt;/strong&gt; – contain descriptive information (dates, products, customers).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relationships&lt;/strong&gt; – links between tables that allow Power BI to filter and calculate correctly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A clean model makes your reports faster, your calculations easier, and your DAX formulas more accurate.&lt;/p&gt;

&lt;p&gt;Once your data model is organized, you can start adding DAX logic to create measures, calculations, and business rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Data Analysis Expressions(&lt;em&gt;DAX)&lt;/em&gt; To create Business Logic
&lt;/h2&gt;

&lt;p&gt;With a clean data we use &lt;em&gt;dax&lt;/em&gt; to create calculations questions. &lt;br&gt;
Dax is used for:&lt;br&gt;
-conditional logic &lt;br&gt;
-time intelligence&lt;br&gt;
-Measures ratios and percentages&lt;/p&gt;

&lt;p&gt;Examples of &lt;strong&gt;Dax&lt;/strong&gt; measure&lt;br&gt;
Total Sales =&lt;br&gt;
SUM(Fact Sales[Sales Amount])&lt;/p&gt;

&lt;p&gt;Sales Growth =&lt;br&gt;
DIVIDE([Total Sales] - [Last Year Sales], [Last Year Sales])&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Simple and Clean Dashboards
&lt;/h2&gt;

&lt;p&gt;An effective dashboard presents only the most important metrics, allowing users to understand insights at a glance without being overwhelmed by unnecessary visuals. By prioritizing key KPIs, using consistent layouts analysts create dashboards that are intuitive, easy to navigate, and focused on actionable insights. &lt;/p&gt;

&lt;p&gt;Common Power BI visuals are like;&lt;/p&gt;

&lt;p&gt;-Bar graphs and column chats&lt;/p&gt;

&lt;p&gt;-Line charts for trends&lt;/p&gt;

&lt;p&gt;-KPI cards&lt;/p&gt;

&lt;p&gt;-Tables and matrices for detail&lt;/p&gt;

&lt;p&gt;-Maps for geographic analysis&lt;/p&gt;

&lt;p&gt;Using Power Query to clean and &lt;strong&gt;Dax&lt;/strong&gt;, adding logic to data you can transform raw data into meaningful insights.&lt;/p&gt;

&lt;p&gt;Inconclusion cleaning and preparing data is the basic foundation of every Insightful &lt;strong&gt;Power BI&lt;/strong&gt; . When you build a clear data model and choose the rightful visuals, your dashboards become intuitive data or report. &lt;/p&gt;

</description>
      <category>powerbi</category>
      <category>tutorial</category>
      <category>begginer</category>
    </item>
    <item>
      <title>#Schemas and Data Modelling in Power BI</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Sun, 01 Feb 2026 22:01:17 +0000</pubDate>
      <link>https://dev.to/victak36lgtm/schemas-and-data-modelling-in-power-bi-1ad9</link>
      <guid>https://dev.to/victak36lgtm/schemas-and-data-modelling-in-power-bi-1ad9</guid>
      <description>&lt;h2&gt;
  
  
  Schemas and Data Modelling in Power BI
&lt;/h2&gt;

&lt;p&gt;Data modelling is one of the most important steps in Power BI. A well-designed data model improves performance, accuracy, and ease to analyse, while a poor model can lead to slow reports and incorrect insights.&lt;/p&gt;

&lt;p&gt;This article explains schemas and data modelling concepts in Power BI.&lt;/p&gt;




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

&lt;p&gt;Data Modelling involves organizing data sources into a structured model. In Power BI, this means organizing tables and defining relationships between them to support accurate reporting and efficient calculations.&lt;/p&gt;




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

&lt;p&gt;A schema is the structure and organization of data in a table. It's the logical arrangement of tables used in reports on Power BI.&lt;/p&gt;

&lt;p&gt;In Power BI, schemas help determine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How data is connected&lt;/li&gt;
&lt;li&gt;How filters flow between tables&lt;/li&gt;
&lt;li&gt;How efficiently queries are executed. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;****Types of schemas in Power BI.&lt;/p&gt;

&lt;p&gt;-Galaxy schema&lt;br&gt;
-Snowflakes schema&lt;br&gt;
-star schema&lt;/p&gt;

&lt;h2&gt;
  
  
  Snowflakes schema
&lt;/h2&gt;

&lt;p&gt;Here dimensions are split into sub dimensions, that can also be split into further smaller tables. &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.amazonaws.com%2Fuploads%2Farticles%2Fzf3acrco6ua0tqlb8j33.jpg" 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.amazonaws.com%2Fuploads%2Farticles%2Fzf3acrco6ua0tqlb8j33.jpg" alt="_snowflake diagram_" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Star schema&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;It's the mostly schema used in Excel, where it has multiple dimensions and one fact table.&lt;br&gt;
its advantages are; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster query performance&lt;/li&gt;
&lt;li&gt;Easier to write DAX formulas&lt;/li&gt;
&lt;li&gt;Better filter
-Easy to understand.&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.amazonaws.com%2Fuploads%2Farticles%2F9hcmxfxrx8y4hbcc9bll.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.amazonaws.com%2Fuploads%2Farticles%2F9hcmxfxrx8y4hbcc9bll.png" alt="_star schema image_" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Fact Tables
&lt;/h2&gt;

&lt;p&gt;A fact table stores quantitative data (measures) that can be analysed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics of Fact Tables:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Contain numerical values&lt;/li&gt;
&lt;li&gt;Have many rows&lt;/li&gt;
&lt;li&gt;Reference dimension tables using keys&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Costomer Id&lt;/li&gt;
&lt;li&gt;Name&lt;/li&gt;
&lt;li&gt;Age&lt;/li&gt;
&lt;li&gt;Region&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Dimension Tables
&lt;/h2&gt;

&lt;p&gt;A dimension table contains descriptive information that provides context to facts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics of Dimension Tables:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Contain text or categorical data&lt;/li&gt;
&lt;li&gt;Have fewer rows than fact tables&lt;/li&gt;
&lt;li&gt;Used for filtering and grouping data&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Date&lt;/li&gt;
&lt;li&gt;Product&lt;/li&gt;
&lt;li&gt;Customer ID&lt;/li&gt;
&lt;li&gt;Location&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Is a Relationship in Power BI?
&lt;/h2&gt;

&lt;p&gt;A relationship connects a column in one table to a column in another table, usually through a key.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Sales[ProductID] → Product[ProductID]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows Power BI to understand how records relate across tables.&lt;/p&gt;




&lt;h2&gt;
  
  
  Relationship Types in Power BI
&lt;/h2&gt;

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

&lt;p&gt;This is the most common and recommended relationship type.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One record in a dimension table&lt;/li&gt;
&lt;li&gt;Many matching records in a fact table&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;One product → many sales records&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Used in star schemas.&lt;/p&gt;




&lt;h3&gt;
  
  
  Many-to-Many (&lt;em&gt;:&lt;/em&gt;)
&lt;/h3&gt;

&lt;p&gt;Occurs when both tables contain duplicate values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can cause ambiguous results&lt;/li&gt;
&lt;li&gt;Should be avoided when possible&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use only when necessary and with caution.&lt;/p&gt;




&lt;h3&gt;
  
  
  One-to-One (1:1)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Each value appears once in both tables&lt;/li&gt;
&lt;li&gt;Rarely used in analytical models&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Relationship Direction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Single Direction (Recommended)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Filters flow from dimension tables to fact tables&lt;/li&gt;
&lt;li&gt;Predictable and efficient behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Best practice for star schemas.&lt;/p&gt;




&lt;h3&gt;
  
  
  Both Direction (Bi-Directional)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Filters flow both ways&lt;/li&gt;
&lt;li&gt;Can cause confusion and performance issues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use only when absolutely necessary.&lt;/p&gt;




&lt;h2&gt;
  
  
  Relationships in Star Schema
&lt;/h2&gt;

&lt;p&gt;In a star schema:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All dimension tables connect directly to the fact table&lt;/li&gt;
&lt;li&gt;Relationships are one-to-many&lt;/li&gt;
&lt;li&gt;Filter direction is single&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This results in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster performance&lt;/li&gt;
&lt;li&gt;Simpler DAX formulas&lt;/li&gt;
&lt;li&gt;Accurate filtering&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Relationships in Snowflake Schema
&lt;/h2&gt;

&lt;p&gt;In a snowflake schema:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dimension tables connect to other dimension tables&lt;/li&gt;
&lt;li&gt;More relationships are required&lt;/li&gt;
&lt;li&gt;More joins occur during queries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce performance in Power BI&lt;/li&gt;
&lt;li&gt;Complicate filter behavior&lt;/li&gt;
&lt;li&gt;Make DAX harder to write and maintain&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why Relationships Matter in Power BI
&lt;/h2&gt;

&lt;p&gt;Correct relationships:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure accurate calculations&lt;/li&gt;
&lt;li&gt;Control how filters behave&lt;/li&gt;
&lt;li&gt;Improve report performance&lt;/li&gt;
&lt;li&gt;Prevent incorrect totals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Poor relationships can lead to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incorrect results&lt;/li&gt;
&lt;li&gt;Slow visuals&lt;/li&gt;
&lt;li&gt;Broken slicers and filters&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Best Practices for Power BI Relationships
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use star schema whenever possible&lt;/li&gt;
&lt;li&gt;Keep relationships one-to-many&lt;/li&gt;
&lt;li&gt;Use single-direction filtering&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - Avoid many-to-many relationships
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Good data modelling is the foundation of effective Power BI reporting. By using well-structured schemas such as the star and snowflake schema and defining correct relationships, you can improve performance, ensure accurate calculations, and create reports that are easy to understand and maintain. Investing time in proper modelling leads to faster insights and more reliable decision-making.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
