<?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: Erickson mugendi</title>
    <description>The latest articles on DEV Community by Erickson mugendi (@cruqza3).</description>
    <link>https://dev.to/cruqza3</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%2F3952227%2F9daa4432-2e87-47af-a4c3-9c1f2015c6de.png</url>
      <title>DEV Community: Erickson mugendi</title>
      <link>https://dev.to/cruqza3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cruqza3"/>
    <language>en</language>
    <item>
      <title>Python Basics</title>
      <dc:creator>Erickson mugendi</dc:creator>
      <pubDate>Sun, 04 Oct 2026 08:54:05 +0000</pubDate>
      <link>https://dev.to/cruqza3/python-basics-29a0</link>
      <guid>https://dev.to/cruqza3/python-basics-29a0</guid>
      <description>&lt;h1&gt;
  
  
  Started Learning Python?
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Variables: names for values
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;variable&lt;/strong&gt; is a name that points at a value. You create one with &lt;code&gt;=&lt;/code&gt;, and Python reads the line from right to left: it works out the right side first, then attaches the name on the left.&lt;/p&gt;

&lt;p&gt;If you have used a spreadsheet, you may expect a name to behave like a formula cell. It does not. Watch what happens to &lt;code&gt;total&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;quantity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&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;quantity&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;55&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;10&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;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





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

&lt;/div&gt;



&lt;p&gt;Python worked out &lt;code&gt;3 * 55&lt;/code&gt; when it reached that line and stored 165. Changing &lt;code&gt;quantity&lt;/code&gt; afterwards does not reach back and redo the sum. To get 550 you run the &lt;code&gt;total&lt;/code&gt; line again, after the change.&lt;/p&gt;

&lt;p&gt;This is also why &lt;code&gt;takings = takings + 660&lt;/code&gt; makes sense. The right side runs first, using the old value, and the result takes the name.&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;takings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;takings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;takings&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;660&lt;/span&gt;
&lt;span class="n"&gt;takings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;takings&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;600&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;takings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;takings&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;100&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;takings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





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

&lt;/div&gt;



&lt;p&gt;The last two lines show &lt;code&gt;+=&lt;/code&gt;, a shorthand for the same pattern.&lt;/p&gt;

&lt;h3&gt;
  
  
  Choosing names
&lt;/h3&gt;

&lt;p&gt;A name can hold letters, digits and underscores. It cannot start with a digit or contain a space. Capitals count, so &lt;code&gt;Bread&lt;/code&gt; and &lt;code&gt;bread&lt;/code&gt; are two different names. The usual style is lowercase words joined by underscores, as in &lt;code&gt;bread_sold&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Name a value for what it means, not for what type it is. &lt;code&gt;bread_sold&lt;/code&gt; tells the next reader something. &lt;code&gt;my_int&lt;/code&gt; tells them nothing. You read code far more often than you write it, so spend the extra few seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two ways a name goes wrong
&lt;/h3&gt;

&lt;p&gt;The first is a typo:&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;bread_sold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&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;bread_sld&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Traceback (most recent call last):
  File "shop.py", line 2, in &amp;lt;module&amp;gt;
    print(bread_sld)
          ^^^^^^^^^
NameError: name 'bread_sld' is not defined. Did you mean: 'bread_sold'?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read an error from the bottom. The last line says what went wrong, and the lines above say where.&lt;/p&gt;

&lt;p&gt;The second is a name that starts with a digit:&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="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;st_item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bread&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
  File "shop.py", line 1
    1st_item = "bread"
    ^
SyntaxError: invalid decimal literal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python rejects this before the program runs at all, because the line is not valid Python.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data types: what kind of value is it?
&lt;/h2&gt;

&lt;p&gt;Every value has a &lt;strong&gt;data type&lt;/strong&gt;, and the type decides what you can do with it. Four cover most of a beginner's needs, and the shop uses all of them:&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;loaves&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;
&lt;span class="n"&gt;sugar_kg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.75&lt;/span&gt;
&lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bread&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;in_stock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&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;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loaves&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sugar_kg&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;in_stock&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;class 'int'&amp;gt; &amp;lt;class 'float'&amp;gt; &amp;lt;class 'str'&amp;gt; &amp;lt;class 'bool'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An &lt;code&gt;int&lt;/code&gt; is a whole number (loaves), a &lt;code&gt;float&lt;/code&gt; has a decimal point (kilograms of sugar), a &lt;code&gt;str&lt;/code&gt; is text (the item name) and a &lt;code&gt;bool&lt;/code&gt; is &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt; (is it in stock). The &lt;code&gt;type()&lt;/code&gt; function tells you what Python thinks a value is. &lt;/p&gt;

&lt;h3&gt;
  
  
  Numbers
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; do what you expect. &lt;code&gt;/&lt;/code&gt; always gives a decimal, &lt;code&gt;//&lt;/code&gt; divides and drops the remainder, &lt;code&gt;%&lt;/code&gt; gives only the remainder, and &lt;code&gt;**&lt;/code&gt; raises to a power. Two conversions are worth seeing next to them:&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="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;9.99&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="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;9.99&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="mi"&gt;7&lt;/span&gt; &lt;span class="o"&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;7&lt;/span&gt; &lt;span class="o"&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;7&lt;/span&gt; &lt;span class="o"&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;7&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;9
10
3.5 3 1 49
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;int(9.99)&lt;/code&gt; gives 9, because &lt;code&gt;int()&lt;/code&gt; cuts off the decimal part and does not round. Use &lt;code&gt;round()&lt;/code&gt; when you want 10.&lt;/p&gt;

&lt;p&gt;Decimals have a catch of their own:&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;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.1&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;price&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;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&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;3&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





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

&lt;/div&gt;



&lt;p&gt;Computers store decimals in binary, and some decimal fractions have no exact binary form, just as one third has no exact decimal form. The tiny error shows up when you print. Round for display. For real money, keep whole units (cents, not dollars) or use Python's &lt;code&gt;decimal&lt;/code&gt; module.&lt;/p&gt;

&lt;h3&gt;
  
  
  Text
&lt;/h3&gt;

&lt;p&gt;Text goes inside quotes, single or double. Pick one style and stay with 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="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;  bread &lt;/span&gt;&lt;span class="sh"&gt;"&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;item&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;item&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;title&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;20&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;Sunrise&lt;/span&gt;&lt;span class="sh"&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; &lt;/span&gt;&lt;span class="sh"&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;Corner Shop&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;8
Bread
--------------------
Sunrise Corner Shop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;len()&lt;/code&gt; counts characters, including the spaces at both ends. &lt;code&gt;strip()&lt;/code&gt; removes those spaces and &lt;code&gt;title()&lt;/code&gt; capitalises each word, which matters in a moment, because people type items with stray spaces. Multiplying text repeats it, so &lt;code&gt;"-" * 20&lt;/code&gt; draws a line on a receipt. A &lt;code&gt;+&lt;/code&gt; between two strings joins them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mixing types
&lt;/h3&gt;

&lt;p&gt;Python will not add text to a number:&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;loaves&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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loaves&lt;/span&gt; &lt;span class="o"&gt;+&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Traceback (most recent call last):
  File "shop.py", line 2, in &amp;lt;module&amp;gt;
    print(loaves + 5)
          ~~~~~~~^~~
TypeError: can only concatenate str (not "int") to str
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The refusal has a reason. A &lt;code&gt;+&lt;/code&gt; between text means "join", and a &lt;code&gt;+&lt;/code&gt; between numbers means "add". With one of each, Python cannot tell which you want, so it stops. You choose by converting one side:&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;loaves&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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&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;loaves&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&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;loaves&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="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





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

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;int("5") + 5&lt;/code&gt; adds and gives 10. &lt;code&gt;"5" + str(5)&lt;/code&gt; joins and gives the text &lt;code&gt;55&lt;/code&gt;. The converters are &lt;code&gt;int()&lt;/code&gt;, &lt;code&gt;float()&lt;/code&gt; and &lt;code&gt;str()&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  True and False
&lt;/h3&gt;

&lt;p&gt;A comparison produces a boolean. Combine booleans with &lt;code&gt;and&lt;/code&gt; (both true), &lt;code&gt;or&lt;/code&gt; (at least one true) and &lt;code&gt;not&lt;/code&gt; (flip 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="n"&gt;loaves&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;is_weekend&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;low_stock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loaves&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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;low_stock&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;is_weekend&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;low_stock&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;is_weekend&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="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;low_stock&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





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

&lt;/div&gt;



&lt;p&gt;Other types turn into booleans too, and one result surprises people:&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="nf"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;False&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;bool&lt;/span&gt;&lt;span class="p"&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;bool&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="nf"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





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

&lt;/div&gt;



&lt;p&gt;Any text with something in it counts as true, even the text &lt;code&gt;"False"&lt;/code&gt;. Empty text and zero count as false.&lt;/p&gt;

&lt;h2&gt;
  
  
  Input and output: talking to the program
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;print()&lt;/code&gt; accepts any number of values and puts a space between them. The &lt;code&gt;sep&lt;/code&gt; option changes that separator. An &lt;strong&gt;f-string&lt;/strong&gt;, a string that starts with &lt;code&gt;f&lt;/code&gt;, lets you put values inside &lt;code&gt;{}&lt;/code&gt;. A format after a colon controls how the value looks: &lt;code&gt;&amp;lt;10&lt;/code&gt; pads to ten characters, left-aligned, and &lt;code&gt;&amp;gt;8.2f&lt;/code&gt; right-aligns in eight characters with two decimals.&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;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bread&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="mf"&gt;55.0&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;Item:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Price:&lt;/span&gt;&lt;span class="sh"&gt;"&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="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;Item:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Price:&lt;/span&gt;&lt;span class="sh"&gt;"&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;sep&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;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;item&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mf"&gt;8.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="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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;10&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="mi"&gt;3&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mf"&gt;8.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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Item: bread Price: 55.0
Item: | bread | Price: | 55.0
bread        55.00
bread       165.00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last two lines show how receipt columns line up.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;input()&lt;/code&gt; shows a prompt, waits, and returns what the person typed. It always returns text, even when they typed a number:&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;quantity&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 loaves? &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="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quantity&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;quantity&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
How many loaves? 3
&amp;lt;class 'str'&amp;gt;
33
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing crashed, and the answer is wrong. &lt;code&gt;"3" * 2&lt;/code&gt; repeats the text, so the result is &lt;code&gt;33&lt;/code&gt;, not 6. A program that fails loudly is easier to fix than one that quietly gives a wrong answer. Convert as soon as the value arrives: &lt;code&gt;quantity = int(input("How many loaves? "))&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic syntax: the rules that hold it together
&lt;/h2&gt;

&lt;p&gt;Python has few syntax rules and enforces them strictly. Four come up in nearly every program.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blocks and indentation
&lt;/h3&gt;

&lt;p&gt;Python marks a block of code by indenting it, usually four spaces. A line that ends in a colon (&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;elif&lt;/code&gt;, &lt;code&gt;else&lt;/code&gt;) opens a block, and the indented lines under it belong to that block.&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;takings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1260&lt;/span&gt;
&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;takings&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;target&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;Target reached&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;takings&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;target&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;Close to target&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;Below target&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Close to target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python checks the conditions from the top. &lt;code&gt;1260 &amp;gt;= 1500&lt;/code&gt; is false. &lt;code&gt;1260 &amp;gt;= 0.8 * 1500&lt;/code&gt; is &lt;code&gt;1260 &amp;gt;= 1200&lt;/code&gt;, which is true, so it prints "Close to target" and skips the &lt;code&gt;else&lt;/code&gt;. Only the first matching branch runs.&lt;/p&gt;

&lt;p&gt;Forget the indentation and Python stops:&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;bread_sold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;bread_sold&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="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;busy day&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
  File "shop.py", line 3
    print("busy day")
    ^
IndentationError: expected an indented block after 'if' statement on line 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  One equals sign or two
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;=&lt;/code&gt; stores a value. &lt;code&gt;==&lt;/code&gt; compares two values. Mixing them up in a condition is a common slip:&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;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;
&lt;span class="k"&gt;if&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;100&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;hit&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; File "shop.py", line 2
    if total = 100:
       ^^^^^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Capitals count
&lt;/h3&gt;

&lt;p&gt;Every built-in function is lowercase, and Python treats &lt;code&gt;Print&lt;/code&gt; as a different name from &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="nc"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Traceback (most recent call last):
  File "shop.py", line 1, in &amp;lt;module&amp;gt;
    Print("hello")
    ^^^^^
NameError: name 'Print' is not defined. Did you mean: 'print'?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Comments
&lt;/h3&gt;

&lt;p&gt;A &lt;code&gt;#&lt;/code&gt; makes Python ignore the rest of the line. Use comments to say why the code does something. &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>SubQueries &amp; CTEs</title>
      <dc:creator>Erickson mugendi</dc:creator>
      <pubDate>Wed, 26 Aug 2026 01:35:36 +0000</pubDate>
      <link>https://dev.to/cruqza3/subqueries-ctes-5h5</link>
      <guid>https://dev.to/cruqza3/subqueries-ctes-5h5</guid>
      <description>&lt;h2&gt;
  
  
  CTE (Common Table Expression)
&lt;/h2&gt;

&lt;p&gt;Its  a temporary result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. Think of it as a &lt;strong&gt;&lt;em&gt;"query variable"&lt;/em&gt;&lt;/strong&gt; — you define it once at the top, then reference it by name anywhere in your main query.&lt;/p&gt;

&lt;p&gt;One rule worth keeping across all of them: name the CTE after what it contains, not what it does. &lt;em&gt;𝗱𝗿𝗶𝘃𝗲𝗿&lt;/em&gt;𝘁𝗿𝗶𝗽&lt;em&gt;𝗰𝗼𝘂𝗻𝘁s&lt;/em&gt; tells the next reader what's in the result set before they read a single line of the definition. &lt;strong&gt;&lt;em&gt;temp1&lt;/em&gt;&lt;/strong&gt; tells them nothing;&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%2Fonsuigpyx02fj4vptqw2.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%2Fonsuigpyx02fj4vptqw2.png" alt="*An example of a CTE*" width="799" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;WITH&lt;/em&gt;&lt;/strong&gt; keyword is used to introduce a CTE with the name                    &lt;strong&gt;&lt;em&gt;&lt;em&gt;vehicle_total&lt;/em&gt;&lt;/em&gt;&lt;/strong&gt; in this case defining the name of the cte for easy calling in the main query.&lt;/p&gt;

&lt;p&gt;CTES are useful during deduplication during data cleaning:&lt;br&gt;
     Below I used a CTE to delete duplicate rows in my Postgres database.&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%2Fknjpvkxixt8kvr9nd2vn.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%2Fknjpvkxixt8kvr9nd2vn.png" alt="*___NOTE:___ Delete was done after verification*" width="800" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Delete is unreversible operation Use Select first to verify Duplicates&lt;/p&gt;

&lt;h2&gt;
  
  
  Recursive CTEs
&lt;/h2&gt;

&lt;p&gt;Recursive CTEs reference themselves till it hits a stopping point. They are useful executing hierarchical data. &lt;br&gt;
Recursive CTEs have to follow 3 procedures for effectivity;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;The Anchor Member:&lt;/code&gt; Runs exactly once at the beginning to establish your starting point.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;The Recursive Member:&lt;/code&gt; The loop engine. It executes repeatedly, taking the output of the previous step and joining it back against the source table to find the next level down.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;The Termination Condition:&lt;/code&gt; Hidden inside the JOIN logic. The loop automatically breaks when a query execution yields zero new matching rows:&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%2F28vvc0n1mk6w0dg2tna5.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%2F28vvc0n1mk6w0dg2tna5.png" alt=" " width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The query starts with the anchor where the top-management does not have managers and assigns it level 1, this is where the loop builds on.&lt;br&gt;
The &lt;code&gt;UNION ALL&lt;/code&gt; in this statement Combines anchor and recursive results while preserving all rows without deduplication.&lt;br&gt;
The recursive member joins employees back to the CTE itself (organization) to walk down the hierarchy one level at a time.&lt;br&gt;
here is the point the real recursion occurs as the loop runs  it finds the next layer down in the org chart and increments the level counter.&lt;/p&gt;

&lt;h2&gt;
  
  
  SUBQUERIES
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;subquery&lt;/strong&gt; is a query placed inside another SQL statement. It is wrapped in parentheses, and its result is used by the outer query.&lt;br&gt;
Here is an example of a subquery, I used it to find what rows are duplicated of BK006 that will be deleted:&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%2Fvthf3kcjwqyz7ojd7tlz.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%2Fvthf3kcjwqyz7ojd7tlz.png" alt=" " width="769" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From this Image:&lt;br&gt;
 It finds all duplicate rows for &lt;code&gt;booking_id = 'BK0006'&lt;/code&gt; while keeping the first physical row (lowest &lt;code&gt;ctid&lt;/code&gt;) and discarding the rest.&lt;br&gt;
The subquery finds the smallest &lt;code&gt;ctid&lt;/code&gt; for that booking.&lt;br&gt;
The outer query returns every row for &lt;code&gt;BK0006&lt;/code&gt; except that first one. which is useful for cleaning.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Connecting Power BI to SQL Databases: From Local Servers to Cloud Platforms</title>
      <dc:creator>Erickson mugendi</dc:creator>
      <pubDate>Tue, 14 Jul 2026 03:12:35 +0000</pubDate>
      <link>https://dev.to/cruqza3/connecting-power-bi-to-sql-databases-from-local-servers-to-cloud-platforms-19mm</link>
      <guid>https://dev.to/cruqza3/connecting-power-bi-to-sql-databases-from-local-servers-to-cloud-platforms-19mm</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;When doing doing armature database creation and data storage for in local machine the type of connection mostly required is quite simple.&lt;br&gt;
Large organizations and large files storage require bigger and sometimes very large storage, this is where the term &lt;strong&gt;Cloud&lt;/strong&gt; comes in.&lt;br&gt;
Companies like Microsoft, oracle, Aws, Digital ocean &lt;em&gt;etc&lt;/em&gt; provides this services.&lt;/p&gt;

&lt;h2&gt;
  
  
  local Database connection
&lt;/h2&gt;

&lt;p&gt;Depending on the type of database a user is using, one can choose what Database Management System to use.&lt;br&gt;
Several &lt;strong&gt;DBMS&lt;/strong&gt; platforms exist but one &lt;strong&gt;Dbeaver&lt;/strong&gt; is a universal and is what we will focus on.&lt;br&gt;
To connect to your local database on dbeaver you will need:&lt;/p&gt;

&lt;p&gt;1.PostgreSQL Installed&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Ensure PostgreSQL is installed on your computer.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;PostgreSQL Server&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;PostgreSQL service running&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;
&lt;br&gt;
&lt;/blockquote&gt;

&lt;p&gt;2.Database Details&lt;br&gt;
You'll need these connection details:&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Field    Example&lt;br&gt;
   Host localhost or 127.0.0.1&lt;br&gt;
   Port 5432 (default)&lt;br&gt;
   Database postgres or your database name (e.g., sales_db)&lt;br&gt;
   Username postgres&lt;br&gt;
   Password The password you set during PostgreS installation&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;3.DBeaver&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Download and install DBeaver Community Edition if you haven't   already.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;4.PostgreSQL JDBC Driver&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The first time you create a PostgreSQL connection in DBeaver, it will ask to download the PostgreSQL JDBC driver.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;Click Download. DBeaver installs it automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to conect
&lt;/h3&gt;

&lt;p&gt;Step 1&lt;/p&gt;

&lt;p&gt;Open DBeaver.&lt;/p&gt;

&lt;p&gt;Step 2&lt;/p&gt;

&lt;p&gt;Click:&lt;/p&gt;

&lt;p&gt;Database&lt;br&gt;
→ New Database Connection&lt;/p&gt;

&lt;p&gt;or click the New Connection icon.&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%2Fxfqtcu1mgw3ymxqk0mdm.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxfqtcu1mgw3ymxqk0mdm.jpg" alt="new database" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 3&lt;/p&gt;

&lt;p&gt;Choose&lt;/p&gt;

&lt;p&gt;PostgreSQL&lt;/p&gt;

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

&lt;p&gt;Step 4&lt;/p&gt;

&lt;p&gt;Enter your connection details.&lt;/p&gt;

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

&lt;p&gt;Host:&lt;br&gt;
localhost&lt;/p&gt;

&lt;p&gt;Port:&lt;br&gt;
5432&lt;/p&gt;

&lt;p&gt;Database:&lt;br&gt;
postgres&lt;/p&gt;

&lt;p&gt;Username:&lt;br&gt;
postgres&lt;/p&gt;

&lt;p&gt;Password:&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%2F12xzn24z3mzksxncere9.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%2F12xzn24z3mzksxncere9.png" alt="enter credentials" width="800" height="799"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 5&lt;/p&gt;

&lt;p&gt;Click&lt;/p&gt;

&lt;p&gt;Test Connection&lt;/p&gt;

&lt;p&gt;If successful, you'll see:&lt;/p&gt;

&lt;p&gt;Connected&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%2Fa6k6bb0zjkh1cxar3ro6.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%2Fa6k6bb0zjkh1cxar3ro6.png" alt="successful connection" width="800" height="623"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;h1&gt;
  
  
  Connecting to a cloud Database
&lt;/h1&gt;

&lt;p&gt;Today organizations increasingly store their data in online &lt;strong&gt;cloud-hosted&lt;/strong&gt; databases rather than on local servers. These databases provide secure access over the internet, making it easy for teams in different locations to work with the same data.&lt;/p&gt;

&lt;p&gt;How the Connection Works&lt;br&gt;
Online Database&lt;br&gt;
(AWS, Azure, Aiven, GCP)&lt;br&gt;
        │&lt;br&gt;
        │ Internet&lt;br&gt;
        ▼&lt;br&gt;
Power BI Desktop&lt;br&gt;
        │&lt;br&gt;
        ▼&lt;br&gt;
Power Query&lt;br&gt;
        │&lt;br&gt;
        ▼&lt;br&gt;
Reports &amp;amp; Dashboards&lt;/p&gt;

&lt;h3&gt;
  
  
  lets connect power bi to Aiven SQl database
&lt;/h3&gt;

&lt;h5&gt;
  
  
  Step 1: Install the MySQL Connector
&lt;/h5&gt;

&lt;p&gt;Power BI uses the MySQL Connector/NET driver to communicate with MySQL databases.&lt;/p&gt;

&lt;p&gt;If it isn't already installed:&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%2Fv7nactm7kduhr8ctm1si.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv7nactm7kduhr8ctm1si.jpg" alt="Install driver" width="800" height="579"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Download MySQL Connector/NET from Oracle.&lt;br&gt;
Install it.&lt;br&gt;
Restart Power BI.&lt;/p&gt;

&lt;h5&gt;
  
  
  Step 2: Connect from Power BI
&lt;/h5&gt;

&lt;p&gt;Open Power BI Desktop.&lt;/p&gt;

&lt;p&gt;Go to:&lt;/p&gt;

&lt;p&gt;Home&lt;br&gt;
→ Get Data&lt;br&gt;
→ MySQL Database&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%2F3iusr76d85rd159clvpf.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3iusr76d85rd159clvpf.jpg" alt="getting data" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Step 4: Enter the Server Information
&lt;/h5&gt;

&lt;p&gt;In the Server field, enter:&lt;/p&gt;

&lt;p&gt;mysql-demo.aivencloud.com:15432&lt;/p&gt;

&lt;p&gt;Replace the hostname and port with the values from your Aiven dashboard.&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%2Fwjhxgcljopo0j3zqjrbv.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%2Fwjhxgcljopo0j3zqjrbv.png" alt="authentication" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Choose Database Authentication.&lt;/p&gt;

&lt;p&gt;Enter:&lt;/p&gt;

&lt;p&gt;Username:&lt;br&gt;
avnadmin&lt;/p&gt;

&lt;p&gt;Password:&lt;/p&gt;




&lt;p&gt;Click Connect.&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%2F81zpqu4vt95t9ygdm8ha.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%2F81zpqu4vt95t9ygdm8ha.png" alt="click on the database and enter credentials" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Step 5: SSL Configuration
&lt;/h5&gt;

&lt;p&gt;Aiven requires encrypted connections.&lt;/p&gt;

&lt;p&gt;Aiven mysql doesnt really need SSl certificate as it uses &lt;br&gt;
&lt;em&gt;the database driver (MySQL Connector/NET or Npgsql).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Step 8: Select Tables&lt;/p&gt;

&lt;p&gt;After authentication, the Navigator window appears.&lt;/p&gt;

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

&lt;p&gt;sales&lt;/p&gt;

&lt;p&gt;employees&lt;/p&gt;

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

&lt;p&gt;Choose:&lt;/p&gt;

&lt;p&gt;Load – Import directly into Power BI.&lt;br&gt;
Transform Data – Open Power Query to clean and shape the data before loading.&lt;/p&gt;

&lt;h2&gt;
  
  
  Postgre Database
&lt;/h2&gt;

&lt;h4&gt;
  
  
  connection to postgre service requires ssl certificate
&lt;/h4&gt;

&lt;p&gt;i) click your Windows taskbar search tool, type "Manage computer certificates" (or press Win + R, type certlm.msc, and press Enter) to open the Certificate Manager.&lt;br&gt;
ii) On the left side panel, locate and expand the folder named Trusted Root Certification Authorities.&lt;br&gt;
iii) Right-click the underlying Certificates sub-folder -&amp;gt; Go to All Tasks -&amp;gt; Click Import....&lt;br&gt;
iv) Step into the wizard and click Next. When the file browser opens, change the extension dropdown in the bottom-right corner from "X.509" to "All Files (.)" otherwise, your ca.pem file will stay invisible&lt;br&gt;
v) Select your ca.pem file, click Next through the default locations, and click Finish. Click Yes on the dramatic Windows security warning pop-up.&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%2F7nj6p5irq76u7vm2z116.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%2F7nj6p5irq76u7vm2z116.png" alt="ssl.Pem" width="800" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  then move to certificate and right click to display
&lt;/h6&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%2Frojy2pcp07iw1v3itb1s.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%2Frojy2pcp07iw1v3itb1s.png" alt="click on import" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  ##click browse and navigate to where you stored the ca.certificate
&lt;/h6&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%2Fuz0ti7f9smfbyjj9bikp.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%2Fuz0ti7f9smfbyjj9bikp.png" alt="click browse and follow steps" width="800" height="671"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click next till Finish to install.&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%2F5aejld24haputxwgvp4f.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%2F5aejld24haputxwgvp4f.png" alt="click next" width="800" height="659"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  ##Click Finish to complete installation
&lt;/h6&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%2Fz1c0otdyu77f8juxpiut.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%2Fz1c0otdyu77f8juxpiut.png" alt="Finish" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This point you install and return to powerbi and follow the process above for authentication. You will be connected and ready to transform your data&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Data modelling relationships, joins and schemas in power bi</title>
      <dc:creator>Erickson mugendi</dc:creator>
      <pubDate>Tue, 30 Jun 2026 07:17:04 +0000</pubDate>
      <link>https://dev.to/cruqza3/data-modelling-relationships-joins-and-schemas-in-power-bi-38be</link>
      <guid>https://dev.to/cruqza3/data-modelling-relationships-joins-and-schemas-in-power-bi-38be</guid>
      <description>&lt;p&gt;Data modelling is bringing all the tables, laying them out and connecting relationships between. A well-designed model makes your dashboards faster, easier to maintain, and more scalable.&lt;/p&gt;

&lt;p&gt;A fact table stores measurable business events, such as sales, orders, or transactions. It contains numeric values and foreign keys to related dimension tables.&lt;/p&gt;

&lt;p&gt;A dimension table stores descriptive information such as customer names, product categories, or dates that is used to filter and group facts.&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;One-to-Many
This means one table can be connected to other many tables. 
eg. A landlord can have many rental houses.&lt;/li&gt;
&lt;li&gt;Many-to-Many
eg. many students can have many different courses they are undertaking.
Many-to-many relationships are supported but should be used carefully because they can introduce ambiguity.&lt;/li&gt;
&lt;li&gt;One-One 
Each row matches exactly to one row&lt;/li&gt;
&lt;li&gt;Many-One
This is simply the same relationship viewed from the opposite table.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  JOINS
&lt;/h2&gt;

&lt;p&gt;Used when you want to combine multiple tables physically before loading them into the data model. You do this using the Merge feature.&lt;br&gt;
&lt;code&gt;Inner Join&lt;/code&gt;: Returns only rows where matching keys exist in both tables.&lt;br&gt;
&lt;code&gt;Left Outer Join&lt;/code&gt;: Returns all rows from the first table and matches from the second.&lt;br&gt;
&lt;code&gt;Right Outer Join&lt;/code&gt;: Returns all rows from the second table and matches from the first.&lt;br&gt;
&lt;code&gt;Full Outer&lt;/code&gt;: Returns all rows from both tables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Schemas
&lt;/h2&gt;

&lt;p&gt;A schema is how you structure your data model&lt;br&gt;
Types include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Star schema &lt;br&gt;
There is one central fact table. &lt;br&gt;
There are several surrounding dimension tables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Snowflake Schema&lt;br&gt;
A snowflake schema is like a star schema, but dimension tables are further broken down into smaller related tables.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;PRIMARY KEYS&lt;/code&gt; A primary key is a column that uniquely identifies each row in a table.&lt;br&gt;
&lt;code&gt;FOREIGN KEY&lt;/code&gt; A foreign key is a column in one table that refers to the primary key in another table. Foreign keys are used to connect tables.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Fact table&lt;/code&gt; is a stores events, transactions, or measurable business activities. &lt;br&gt;
&lt;code&gt;Dimension Table&lt;/code&gt; is a describes the items in the fact table. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Data Science and Analytics</title>
      <dc:creator>Erickson mugendi</dc:creator>
      <pubDate>Sat, 06 Jun 2026 13:26:20 +0000</pubDate>
      <link>https://dev.to/cruqza3/data-science-and-analytics-1ban</link>
      <guid>https://dev.to/cruqza3/data-science-and-analytics-1ban</guid>
      <description>&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%2Ftz9s3bdox8i7ijuhpdf4.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%2Ftz9s3bdox8i7ijuhpdf4.jpg" alt="Camp working" width="799" height="371"&gt;&lt;/a&gt;##Data science and analytics&lt;br&gt;
 This has my dream all through and finally am here. I am super excited to start my new journey, week one has been all about data cleaning in excel which excited me as its a field have been heavily involved in career wise, I am diving deep to make data more insightful.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Excel is Used in Real-World Data Analysis
&lt;/h2&gt;

&lt;p&gt;Cleaning data in excel really helps to bring out certain data driven trends clearly.&lt;br&gt;
Forecasting is very useful to predict market trends. Data can be classified into quarters and clearly show how sale trends appear.&lt;br&gt;
Visualization is definitely a feature admired in boardrooms to show case business progress.&lt;br&gt;
ISBLANK, IFERROR are helpful in big datasets to check for errors and blank cells in cleaning. &lt;br&gt;
Turning to Power query is a game changer in connecting to different databases.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
