<?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: Mungai Erick Gachuhi</title>
    <description>The latest articles on DEV Community by Mungai Erick Gachuhi (@flymanreek5).</description>
    <link>https://dev.to/flymanreek5</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%2F4182961%2Fe6155a1e-a93f-4e2a-bee2-54e3a35f5e70.jpg</url>
      <title>DEV Community: Mungai Erick Gachuhi</title>
      <link>https://dev.to/flymanreek5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flymanreek5"/>
    <language>en</language>
    <item>
      <title>LATEST AS A PYTHON BEGINNER : PYTHON FUNCTIONS</title>
      <dc:creator>Mungai Erick Gachuhi</dc:creator>
      <pubDate>Wed, 18 Nov 2026 16:16:18 +0000</pubDate>
      <link>https://dev.to/flymanreek5/latest-as-a-python-beginner-python-functions-fo8</link>
      <guid>https://dev.to/flymanreek5/latest-as-a-python-beginner-python-functions-fo8</guid>
      <description>&lt;p&gt;A function is a named block of code that does one specified job such that once you write it, you can run it as many times as you want by calling it by its name (function name).&lt;/p&gt;

&lt;p&gt;They can be categorized into two.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Built-in Functions&lt;/strong&gt;—These come with Python and must be obeyed to perform properly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User-defined functions&lt;/strong&gt;—Functions one creates to perform a specified task based on the requirement.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Importance of Functions Includes
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Code reasonability&lt;/strong&gt;—You can use the function many times.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code readability&lt;/strong&gt;—Which can tell the reader what happens without having to read every line of code to understand your code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoids repetition&lt;/strong&gt;: You write the logic once instead of copying it&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Example 1: Built-in Functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Arsenal"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# counts the letters, gives 7&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# picks the biggest number, 31&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 2: Avoiding Repetition
&lt;/h3&gt;

&lt;p&gt;Without a function:&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;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Go Arsenal!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Go Chelsea!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Go Liverpool!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a function:&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;cheer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;team&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;          &lt;span class="c1"&gt;# team is the parameter&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'Go {team}!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;cheer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Arsenal'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# 'Arsenal' is the argument&lt;/span&gt;
&lt;span class="nf"&gt;cheer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Chelsea'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;cheer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Liverpool'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 3: Reusing a Function
&lt;/h3&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;calc_points&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;draws&lt;/span&gt;&lt;span class="p"&gt;)&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;wins&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;draws&lt;/span&gt;   &lt;span class="c1"&gt;# win = 3 points, draw = 1&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;calc_points&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;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# Gor Mahia: 34&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;calc_points&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# AFC Leopards: 30&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
      <category>automation</category>
    </item>
    <item>
      <title>SQL BASICS</title>
      <dc:creator>Mungai Erick Gachuhi</dc:creator>
      <pubDate>Mon, 26 Oct 2026 22:59:42 +0000</pubDate>
      <link>https://dev.to/flymanreek5/sql-basics-5c8a</link>
      <guid>https://dev.to/flymanreek5/sql-basics-5c8a</guid>
      <description>&lt;p&gt;During the past few days I have learned a few basics on SQL and would like to share here.&lt;br&gt;
After the first lesson, 'SELECT * FROM table' felt like enough. However, after the third lesson as well as an assignment, I worked with a hospital database of 15 patients. I have now realized the real power is in asking precise questions: &lt;em&gt;Which patients have no insurance? Whose name starts with K? Who needs a phone call because there is no email on file?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this article I walk through the operators I practiced in PostgreSQL using DBeaver, with queries from my own assignment.&lt;/p&gt;

&lt;h2&gt;
  
  
  The dataset
&lt;/h2&gt;

&lt;p&gt;I worked with a 'patients' table with columns such as 'first_name,' 'gender,' 'age,' 'county,' and 'admission_date.' Some emails and insurance values were left empty on purpose, which turned out to be very important later.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1. Comparison operators&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;These compare a column with a value: '=', '&amp;lt;&amp;gt;', '&amp;gt;', '&amp;lt;', '&amp;gt;=' and '&amp;lt;='.&lt;br&gt;
Examples include&lt;br&gt;
-- To select patients from Kisumu County.&lt;br&gt;
The code is:&lt;br&gt;
SELECT * FROM patients WHERE county = 'Kisumu';&lt;/p&gt;

&lt;p&gt;-- Patients admitted on or after 1 April 2026&lt;br&gt;
SELECT * FROM patients WHERE admission_date &amp;gt;= '2026-04-01';&lt;/p&gt;

&lt;p&gt;Text and dates go in single quotes; numbers don't. '&amp;lt;&amp;gt; ' means "not equal to," so 'department' &amp;lt;&amp;gt; 'General' returns everyone outside the General department.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;strong&gt;Logical operators: AND, OR, NOT&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Logical operators combine conditions. 'AND' needs both conditions to be true, 'OR' needs at least one, and 'NOT' reverses a condition.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;br&gt;
-- Male patients over 40, or anyone with a bill above 150,000 (5 rows)&lt;br&gt;
SELECT * FROM patients&lt;br&gt;
WHERE (gender = 'Male' AND age &amp;gt; 40) OR bill_amount &amp;gt; 150000;&lt;/p&gt;

&lt;p&gt;SQL evaluates 'AND' before 'OR,' just like multiplication comes before addition in math. I still use brackets because they show what I mean, and they protect me when conditions get more complicated.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;strong&gt;IN and BETWEEN&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;When I needed patients from Nairobi or Mombasa, I first wrote it with &lt;code&gt;OR&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;An example is &lt;br&gt;
SELECT * FROM patients&lt;br&gt;
WHERE county = 'Nairobi' OR county = 'Mombasa';&lt;/p&gt;

&lt;p&gt;'IN' does the same job in a shorter and cleaner way:&lt;/p&gt;

&lt;p&gt;An example is: &lt;br&gt;
SELECT * FROM patients&lt;br&gt;
WHERE county IN ('Nairobi', 'Mombasa');&lt;/p&gt;

&lt;p&gt;'BETWEEN' filters a range, and it &lt;strong&gt;includes both endpoints&lt;/strong&gt;. For example, 'bill_amount BETWEEN 10000 AND 50000' is the same as 'bill_amount &amp;gt;= 10000 AND bill_amount &amp;lt;= 50000'. It works with dates too, and &lt;code&gt;NOT BETWEEN&lt;/code&gt; returns everything outside the range.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Handling NULL
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt; means a value is missing or unknown. It is not zero, and it is not an empty string. To find missing data, use 'IS NULL' or 'IS NOT NULL':&lt;/p&gt;

&lt;p&gt;An example is:&lt;br&gt;
-- Patients with no email address&lt;br&gt;
SELECT * FROM patients WHERE email IS NULL;&lt;/p&gt;

&lt;p&gt;SELECT * FROM patients&lt;br&gt;
WHERE insurance IS NULL AND bill_amount &amp;gt; 10000&lt;/p&gt;

&lt;p&gt;If you're learning SQL too, build a small table and break these operators on purpose. You'll remember the mistakes much better than the rules.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
