<?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: Joy Nyayieka</title>
    <description>The latest articles on DEV Community by Joy Nyayieka (@joy_nyayieka).</description>
    <link>https://dev.to/joy_nyayieka</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3108521%2Fda5e2c66-24b0-42e7-87f3-96d2e2c469bc.png</url>
      <title>DEV Community: Joy Nyayieka</title>
      <link>https://dev.to/joy_nyayieka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joy_nyayieka"/>
    <language>en</language>
    <item>
      <title>Integrating Pesapal API 3.0 on Django</title>
      <dc:creator>Joy Nyayieka</dc:creator>
      <pubDate>Thu, 11 Sep 2025 09:59:25 +0000</pubDate>
      <link>https://dev.to/joy_nyayieka/integrating-pesapal-api-30-on-django-58i0</link>
      <guid>https://dev.to/joy_nyayieka/integrating-pesapal-api-30-on-django-58i0</guid>
      <description>&lt;p&gt;Pesapal is a fintech company that provides secure and convenient digital payment services to individuals and businesses in African countries, including Kenya, Uganda, Tanzania, Malawi, Rwanda, Zambia, and Zimbabwe. I was recently working on a Django project that required integrating the Pesapal API to facilitate seamless transactions within the application. The first step was to review the Pesapal API &lt;a href="https://developer.pesapal.com/how-to-integrate/e-commerce/api-30-json/api-reference" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;; however, upon further research, it became unclear how exactly to implement this integration into the project. This article aims to provide a more detailed explanation of how to implement the basic steps specifically within a &lt;em&gt;Django&lt;/em&gt; project. &lt;/p&gt;

&lt;h3&gt;
  
  
  1. Set Up Pesapal Account
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to the &lt;a href="https://developer.pesapal.com/how-to-integrate/e-commerce/api-30-json/authentication" rel="noopener noreferrer"&gt;Pesapal Developers Portal&lt;/a&gt;.
&lt;/li&gt;
&lt;li&gt;Create a live/production business account.
&lt;/li&gt;
&lt;li&gt;You will then receive the &lt;em&gt;Consumer Key&lt;/em&gt; and &lt;em&gt;Consumer Secret&lt;/em&gt; on the registered email. &lt;/li&gt;
&lt;li&gt;Ensure your Django project is set up.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Install Required Dependencies
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;requirements.txt&lt;/code&gt; file and install the following dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;requests==2.32.4             # HTTP calls to Pesapal API
python-decouple==3.8         # Manage API keys &amp;amp; secrets via .env
djangorestframework==3.16.0  # Build API endpoints for Pesapal integration

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Configure Environment Variables
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file in your project root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# PesaPal Configuration
PESAPAL_CONSUMER_KEY=your_consumer_key_here
PESAPAL_CONSUMER_SECRET=your_consumer_secret_here
PESAPAL_BASE_URL=https://cybqa.pesapal.com/pesapalv3/api/  # Sandbox
# PESAPAL_BASE_URL=https://pay.pesapal.com/pesapalv3/api/  # Production
PESAPAL_IPN_ID=your_ipn_id_here  # Will be generated in Step 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to your &lt;code&gt;settings.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from decouple import config

# PesaPal Settings
PESAPAL_CONSUMER_KEY = config('PESAPAL_CONSUMER_KEY')
PESAPAL_CONSUMER_SECRET = config('PESAPAL_CONSUMER_SECRET')
PESAPAL_BASE_URL = config('PESAPAL_BASE_URL')
PESAPAL_IPN_ID = config('PESAPAL_IPN_ID', default='')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Create &lt;code&gt;pesapal_service.py&lt;/code&gt; in the Main App
&lt;/h3&gt;

&lt;p&gt;Create the file inside your main app, eg:&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%2Fi4ad29b2qlndil3vngc8.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%2Fi4ad29b2qlndil3vngc8.png" alt=" " width="449" height="370"&gt;&lt;/a&gt;     &lt;/p&gt;

&lt;h4&gt;
  
  
  Purpose of &lt;code&gt;pesapal_service.py&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;This file is the core integration layer between the Django application layer and the Pesapal API. It contains all the functions required to:&lt;/p&gt;

&lt;p&gt;a. Authenticate with Pesapal.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every request to Pesapal requires an OAuth access token.
&lt;/li&gt;
&lt;li&gt;This function calls the RequestToken endpoint and returns a token that is valid for a limited time.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def generate_access_token():
    url = f"{BASE_URL}/api/Auth/RequestToken"
    payload = {
        "consumer_key": settings.PESAPAL_CONSUMER_KEY,
        "consumer_secret": settings.PESAPAL_CONSUMER_SECRET
    }
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json"
    }
    response = requests.post(url, json=payload, headers=headers)
    return response.json().get("token") if response.status_code == 200 else None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;b. Registering IPN URL and fetching registered IPNs.   &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An &lt;a href="https://developer.pesapal.com/how-to-integrate/e-commerce/api-30-json/registeripnurl" rel="noopener noreferrer"&gt;IPN&lt;/a&gt; is an Instant Payment Notification that Pesapal uses to notify your system about payment status changes asynchronously. &lt;/li&gt;
&lt;li&gt;The IPN URL is where Pesapal sends asynchronous updates.&lt;/li&gt;
&lt;li&gt;Fetching registered IPNs verifies which IPNs are active.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def register_ipn_url(access_token, ipn_url):
    url = f"{BASE_URL}/api/URLSetup/RegisterIPN"
    payload = {
        "url": ipn_url,
        "ipn_notification_type": "GET"
    }
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Accept": "application/json",
        "Content-Type": "application/json"
    }
    return requests.post(url, json=payload, headers=headers)

def get_registered_ipns(access_token):
    url = f"{BASE_URL}/api/URLSetup/GetIpnList"
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Accept": "application/json",
        "Content-Type": "application/json"
    }
    return requests.get(url, headers=headers)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;c. Submitting an order.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sends transaction details to Pesapal, eg, the amount and description, and returns a redirect URL where customers can complete the payment on Pesapal's secure checkout page.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def submit_order_request(access_token, payload):
    url = f"{BASE_URL}/api/Transactions/SubmitOrderRequest"
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Accept": "application/json",
        "Content-Type": "application/json"
    }
    return requests.post(url, json=payload, headers=headers)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;d. Checking transaction status.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Important to confirm if a payment was successful before delivering a product or a service.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def get_transaction_status(access_token, tracking_id, merchant_reference):
    url = f"{BASE_URL}/api/Transactions/GetTransactionStatus"
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Accept": "application/json"
    }
    params = {
        "order_tracking_id": tracking_id,
        "order_merchant_reference": merchant_reference
    }
    response = requests.get(url, headers=headers, params=params)

    if response.status_code == 200:
        return response.json().get("payment_status")  # "COMPLETED", "FAILED", etc.
    else:
        return None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is worth &lt;em&gt;noting&lt;/em&gt; that to make the code above production-ready, consider; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Token caching to avoid calling Pesapal for a new token on every request.
&lt;/li&gt;
&lt;li&gt;Wrap with &lt;code&gt;try/except&lt;/code&gt; to ensure error handling.&lt;/li&gt;
&lt;li&gt;Add docstrings to functions to ensure a clear description, args, and return values. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After receiving the payment details, store them in the system under the &lt;code&gt;models.py&lt;/code&gt; file as in this example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.db import models

class Payment(models.Model):
    order_id = models.CharField(max_length=100)
    amount = models.DecimalField(max_digits=10, decimal_places=2)
    status = models.CharField(max_length=50, default='PENDING')
    tracking_id = models.CharField(max_length=100, null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Create Payment Views
&lt;/h3&gt;

&lt;p&gt;Here we define Django views that connect the project to the Pesapal service functions. These views are the entry points for the API consumers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
import uuid
from django.http import JsonResponse, HttpResponse
from django.shortcuts import redirect, render
from django.views.decorators.csrf import csrf_exempt

# Import service functions
from .pesapal_service import (
    generate_access_token,
    register_ipn_url,
    get_registered_ipns,
    submit_order_request,
    get_transaction_status,
)


def get_token_view(request):
    """Generate and return a fresh Pesapal OAuth token (for testing/debugging)."""
    token = generate_access_token(force_refresh=True)
    return JsonResponse({"token": token})


def register_ipn_view(request):
    """Register an IPN URL with Pesapal."""
    ipn_url = request.GET.get("url")
    if not ipn_url:
        return JsonResponse({"error": "IPN URL is required"}, status=400)

    res = register_ipn_url(ipn_url)
    return JsonResponse(res)


def list_ipns_view(request):
    """Fetch all registered IPN URLs from Pesapal for verification."""
    res = get_registered_ipns()
    return JsonResponse(res, safe=False)


def create_order_view(request):
    """
    Create a new Pesapal order and return the redirect URL for checkout.
    Payload includes amount, currency, description, callback, IPN, and billing details.
    """
    # Get amount from request body (JSON or form POST)
    if request.content_type == "application/json":
        data = json.loads(request.body)
        amount = float(data.get("amount", 0))
    else:
        amount = float(request.POST.get("amount", 0))

    payload = {
        "id": str(uuid.uuid4()),  # Unique order ID
        "currency": "KES",
        "amount": amount,
        "description": "Payment description goes here",
        "callback_url": "https://yourdomain.com/pesapal/payment-confirm/",
        "notification_id": "YOUR_REGISTERED_IPN_ID",
        "branch": "Store Name - Example",
        "billing_address": {
            "email_address": "customer@example.com",
            "phone_number": "0723xxxxxx",
            "country_code": "KE",
            "first_name": "Juma",
            "last_name": "Mutua",
            "line_1": "Customer Address",
            "city": "Nairobi",
        },
    }

    res = submit_order_request(payload)

    if "redirect_url" in res:
        return JsonResponse({"redirect_url": res["redirect_url"]})
    else:
        return JsonResponse({"error": "Failed to create order"}, status=400)


@csrf_exempt
def ipn_listener(request):
    """
    Update your database with payment status asynchronously.
    """
    tracking_id = request.GET.get("tracking_id")
    merchant_reference = request.GET.get("merchant_reference")

    print(f"[IPN] Tracking ID: {tracking_id}, Reference: {merchant_reference}")
    return HttpResponse("IPN received", status=200)


def payment_confirm(request):
    """
    Callback endpoint: Pesapal redirects the customer here after payment.
    """
    tracking_id = request.GET.get("order_tracking_id")
    merchant_reference = request.GET.get("order_merchant_reference")

    status_response = get_transaction_status(tracking_id, merchant_reference)
    payment_status = status_response.get("payment_status")

    if payment_status == "COMPLETED":
        return redirect("dashboard")  # Example success page
    else:
        return render(request, "payments/payment-failed.html")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;callback_url&lt;/code&gt; is the URL where a user of the system is redirected after a successful payment using Pesapal. During development, since the system is not live yet, you can make use of &lt;a href="https://ngrok.com/docs" rel="noopener noreferrer"&gt;ngrok&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ngrok&lt;/em&gt; is a reverse proxy that enables a developer to expose a local server running on their machine to the internet. This creates a secure tunnel, giving the local server a public URL that can receive webhooks or API callbacks from services like Pesapal. This is crucial because external APIs need a publicly accessible endpoint to send data back to, which they can't do to a local machine's address like &lt;code&gt;http://localhost&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once you &lt;a href="https://ngrok.com/docs/getting-started/" rel="noopener noreferrer"&gt;create the endpoint&lt;/a&gt;, replace the &lt;code&gt;callback_url&lt;/code&gt; with the valid URL. eg &lt;br&gt;
&lt;code&gt;"callback_url": "https://1234-567-890.ngrok-free.app/dashboard"&lt;/code&gt;. The base URL should also be included in &lt;code&gt;settings.py&lt;/code&gt; under the &lt;code&gt;ALLOWED_HOSTS = [...]&lt;/code&gt;. &lt;/p&gt;
&lt;h3&gt;
  
  
  6. Configure URLs
&lt;/h3&gt;

&lt;p&gt;Under the Main app's &lt;code&gt;urls.py&lt;/code&gt;(specific to this example tutorial), configure the URLs to connect the Pesapal payment views defined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path
from . import views

urlpatterns = [
    # Utility views
    path("pesapal/token/", views.get_token_view, name="pesapal-get-token"),
    path("pesapal/ipn/register/", views.register_ipn_view, name="pesapal-register-ipn"),
    path("pesapal/ipn/list/", views.list_ipns_view, name="pesapal-list-ipns"),

    # Payment flow
    path("pesapal/order/create/", views.create_order_view, name="pesapal-create-order"),
    path("pesapal/ipn/", views.ipn_listener, name="pesapal-ipn-listener"),
    path("pesapal/payment-confirm/", views.payment_confirm, name="pesapal-payment-confirm"),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. Register IPN URL
&lt;/h3&gt;

&lt;p&gt;Get the IPN ID by running &lt;code&gt;https://yourdomain.com/pesapal/ipn/&lt;/code&gt; and replacing the placeholder in the &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Testing
&lt;/h3&gt;

&lt;p&gt;Test the payment flow by checking whether the redirect works, the callback updates the status, and whether the IPN hits the endpoint. When moving to production, switch the API base URL to production and update the keys.&lt;/p&gt;

&lt;p&gt;Before production, you might also consider ensuring security, such as using HTTPS, implementing proper error handling for error logging, and configuring a proper domain for callback URLs. &lt;/p&gt;




&lt;p&gt;Above are the fundamental steps to integrate the Pesapal API into a Django project. Of course, Pesapal has many other services like handling recurring payments, refund request and order cancellation that are not included in the article but are equally useful &lt;a href="https://developer.pesapal.com/how-to-integrate/e-commerce/api-30-json/recurringpayments" rel="noopener noreferrer"&gt;(documentation)&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;I hope you have found this useful! I'd be happy to get your feedback on it. See you in the next one. 🫡&lt;/p&gt;

</description>
      <category>api</category>
      <category>tutorial</category>
      <category>python</category>
      <category>django</category>
    </item>
    <item>
      <title>Python Built-in Data Structures(II)</title>
      <dc:creator>Joy Nyayieka</dc:creator>
      <pubDate>Tue, 13 May 2025 10:23:35 +0000</pubDate>
      <link>https://dev.to/joy_nyayieka/python-built-in-data-structuresii-44gg</link>
      <guid>https://dev.to/joy_nyayieka/python-built-in-data-structuresii-44gg</guid>
      <description>&lt;p&gt;This second article picks up where we left off,  moving from &lt;em&gt;lists&lt;/em&gt; and &lt;em&gt;tuples&lt;/em&gt; to &lt;em&gt;sets&lt;/em&gt; and &lt;em&gt;dictionaries&lt;/em&gt;. By the end of this article, we should get a resounding answer to my Python instructor's question.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sets
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_set = {1, 2, (4, 5)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A set is a collection of unique data; therefore, no element within a set can be duplicated, eg, &lt;code&gt;True&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;They are useful in membership testing because they use a hash table under the hood, and to eliminate duplicate entries, eg, storing information about student IDs. &lt;/p&gt;

&lt;p&gt;Set objects also support mathematical operations like union, intersection, difference, and symmetric difference.&lt;/p&gt;

&lt;h4&gt;
  
  
  Key Features of a Set
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Unordered - elements cannot be accessed in a specific order &lt;/li&gt;
&lt;li&gt;Mutable - elements can be altered after creation.&lt;/li&gt;
&lt;li&gt;No duplicates - elements are all unique.&lt;/li&gt;
&lt;li&gt;Unindexed - items cannot be accessed via indexes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Common Set Methods&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;add()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Adds an element to the set.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;discard()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes an element if present.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;clear()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes all elements.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;copy()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns a shallow copy.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;union()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns the set containing the union of sets.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;intersection()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns a set that is the intersection of two other sets.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;difference()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns a set containing the difference between two or more sets.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;symmetric_difference()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns elements that are in either of the two sets but not in both.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Similar to &lt;a href="https://dev.to/joy_nyayieka_fc5b89b9b20e/python-built-in-data-structuresi-1p2n"&gt;list comprehensions&lt;/a&gt;, set comprehensions are also supported.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;evens = {x for x in range(11) if x % 2 == 0}
print(evens)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output&lt;br&gt;
&lt;code&gt;{0, 2, 4, 6, 8, 10}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When to use Sets&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When carrying out mathematical set operations upon the data, like union or intersection.&lt;/li&gt;
&lt;li&gt;Membership testing - checking if an element exists within a set, which is faster than using a list or tuple.&lt;/li&gt;
&lt;li&gt;Removing duplicates - sets remove duplicates that can be useful in finding the unique count of items.&lt;/li&gt;
&lt;li&gt;Efficient lookups - as a result of the fast membership testing, sets are useful when checking if an item is present in a collection. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Dictionaries
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;phonebook = {'Ali': 0712345, 'Maria': 0721435}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A dictionary stores values in key-value pairs. Similar to real-world dictionaries, each word(key) has a definition(value), requiring the keys to be unique within one dictionary.    &lt;/p&gt;

&lt;h4&gt;
  
  
  Key Features of a Dictionary
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Ordered - as of Python version 3.7&lt;/li&gt;
&lt;li&gt;Keys are case sensitive.&lt;/li&gt;
&lt;li&gt;Keys must be unique - duplicate keys are not allowed&lt;/li&gt;
&lt;li&gt;Internally uses hashing - operations can be performed in constant time. &lt;/li&gt;
&lt;li&gt;Mutable - items can be changed, added or removed after the dictionary has been created. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Common Dictionary Methods&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pop()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes the item with the specified key.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;clear()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes all items from the dictionary.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;keys()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns all the dictionary's keys.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;values()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns all the dictionary's values.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;items()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns a view object that displays a list of dictionary's key-value tuple pairs.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;get()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns the value of the specified key.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;popitem()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes and returns the last key-value pair.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;When to use a Dictionary&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast lookups by unique key. For example, looking up a person's phone number using their name in a contact list.&lt;/li&gt;
&lt;li&gt;When working with data that has a clear mapping. eg, mapping user IDs to the user info.&lt;/li&gt;
&lt;li&gt;When organizing structured data. eg, storing a person's profile with fields like name, age and email.&lt;/li&gt;
&lt;li&gt;When grouping related information together. eg, storing the country name and the capital city.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Comparison of Python Data Structures
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Mutable&lt;/th&gt;
&lt;th&gt;Ordered&lt;/th&gt;
&lt;th&gt;Indexed&lt;/th&gt;
&lt;th&gt;Allows Duplicates&lt;/th&gt;
&lt;th&gt;Key-Value Pairs&lt;/th&gt;
&lt;th&gt;Use Case Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;Storing a sequence of items (e.g., tasks)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tuple&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;Fixed data (e.g., coordinates, RGB values)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;set&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;Unique items collection (e.g., tags)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;dict&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅*&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅ (keys: ❌)&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Key-value mapping (e.g., user profiles)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In conclusion, sets are mutable, not '-utable'. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python Built-in Data Structures(I)</title>
      <dc:creator>Joy Nyayieka</dc:creator>
      <pubDate>Sun, 11 May 2025 20:21:14 +0000</pubDate>
      <link>https://dev.to/joy_nyayieka/python-built-in-data-structuresi-1p2n</link>
      <guid>https://dev.to/joy_nyayieka/python-built-in-data-structuresi-1p2n</guid>
      <description>&lt;p&gt;Recently, a Python instructor asked me whether a set is mutable or immutable. I can't clearly remember what I said, but I did get the last part of the words correct because I remember saying '-utable', which reminded me of the &lt;a href="https://www.youtube.com/shorts/LrdIdprQ914" rel="noopener noreferrer"&gt;viral video&lt;/a&gt; of the backbenchers in a class answering that the pressure 'creases' instead of a comprehensive 'increases' or 'decreases'. This led me to researching the built-in data structures in Python, and below is the first part of the summary of my findings. &lt;/p&gt;

&lt;h3&gt;
  
  
  Lists
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fruits = ["banana", "mango", "watermelon"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists are used to store multiple items in a single variable. They can be defined using square brackets &lt;em&gt;[ ]&lt;/em&gt; or the &lt;em&gt;list&lt;/em&gt; type function&lt;/p&gt;

&lt;h4&gt;
  
  
  Key Features of Lists
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Ordered - maintain the order of elements.&lt;/li&gt;
&lt;li&gt;Mutable - items can be modified after creation.&lt;/li&gt;
&lt;li&gt;Heterogeneous - elements can be of different data types.&lt;/li&gt;
&lt;li&gt;Allow duplicates - can contain duplicate values.&lt;/li&gt;
&lt;li&gt;Indexed - accessing items can be done directly using their index, starting from 0.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It is important to note that lists store references rather than values. Elements in a list are not stored directly in the list structure; rather, the list stores pointers to the actual objects in memory. &lt;/p&gt;

&lt;h5&gt;
  
  
  Common List Operations
&lt;/h5&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;count(x)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns the number of times x appears in the list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;append(x)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Adds x to the end of the list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;insert(i,x)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inserts x at index i&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;remove(x)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Remove the first item with the value x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pop([i])&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Remove item at position i and return it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;clear()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes all items from the list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;reverse()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reverse the elements of the list in place&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;index(x)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns the index of the first value of x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sort()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Lists in ascending or descending order&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;copy()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns the shallow copy of the list&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h5&gt;
  
  
  List Comprehensions
&lt;/h5&gt;

&lt;p&gt;List comprehensions provide a concise way of creating new lists based on the values of an existing list. &lt;br&gt;
For example, we have a list of numbers and we want to generate the square of each element in the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [1, 2, 3, 4]

#List comprehension to create a new list
squared_numbers = [num** 2 for num in numbers]

print(squared_numbers)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output&lt;br&gt;
&lt;code&gt;[1, 4, 9, 16]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When to use Lists&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Storing collections of related items. For example, a program that tracks student names in a classroom would use a list like &lt;code&gt;students = ["Njoroge", "Karen", "Fatuma", "Chebet", "Juma"]&lt;/code&gt; to maintain all names in one organized structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Iterating through sequential data. For example, when sending email notifications to multiple recipients, a program would loop through a list of email addresses to send the same message to each person.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Temporary storage of results. For example, when scraping a website, a program accumulates all URLs in a list before processing them further or saving them to a database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lists allow programmers to create new data collections by transforming or filtering existing data. For example, automatically create a new list with just the scores above 70 for a list of test scores.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Tuples
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_tuple = ("Alice", 15, "Student")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Tuples, like lists, store multiple items in a single variable. The primary difference, however, is that tuples cannot be changed after their creation.&lt;/p&gt;
&lt;h4&gt;
  
  
  Key Features of Tuples
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Ordered - elements are in a specific sequence.&lt;/li&gt;
&lt;li&gt;Immutable - cannot be changed after their creation.&lt;/li&gt;
&lt;li&gt;Defined using parentheses().&lt;/li&gt;
&lt;li&gt;Allow duplicates.&lt;/li&gt;
&lt;li&gt;Heterogeneous - can contain mixed data types.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  Common Tuple Operations
&lt;/h4&gt;

&lt;p&gt;Due to the immutability of tuples, there are only two tuple methods that a tuple object can call. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;count(x)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns the number of times &lt;code&gt;x&lt;/code&gt; appears in tuple&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;index(x)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns the index of the first occurrence of &lt;code&gt;x&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;When to use Tuples&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For efficient looping - useful for looping over fixed data like days of the week in a calendar app.&lt;/li&gt;
&lt;li&gt;Packing/unpacking values - for example, when processing student records, like extracting name and grade from a database tuple.&lt;/li&gt;
&lt;li&gt;Immutable records - good for creating read-only data structures like coordinates or database rows.&lt;/li&gt;
&lt;li&gt;Dictionary keys - tuples of coordinates (latitude, longitude) can be used as dictionary keys to store location details, ensuring consistency and suitability for lookup operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As mentioned before, the fundamental difference between lists and tuples is that lists are mutable while tuples are not. As a result, list object provide more methods but at the cost of memory space. Take the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sys
a_list = ['Maina', 'Football', 1, 3.142, True]
a_tuple = ('Chebet', 'Tennis', 2, 13.31, False)
print('The list size:', sys.getsizeof(a_list), 'bytes')
print('The tuple size:', sys.getsizeof(a_tuple), 'bytes')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Outputs&lt;br&gt;
&lt;code&gt;The list size: 104 bytes&lt;br&gt;
The tuple size: 80 bytes&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This difference becomes more apparent when working with big data. Immutability makes notable optimization as well as making processing much faster, which is efficient when working with millions of sequence objects.&lt;/p&gt;

&lt;p&gt;Thus far, can you explain when to use a list over a tuple and vice versa? And more importantly, for the people at the back, are tuples mutable or immutable?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Introduction to Data Analysis using Microsoft Excel</title>
      <dc:creator>Joy Nyayieka</dc:creator>
      <pubDate>Wed, 30 Apr 2025 08:55:06 +0000</pubDate>
      <link>https://dev.to/joy_nyayieka/introduction-to-data-analysis-using-microsoft-excel-5ac4</link>
      <guid>https://dev.to/joy_nyayieka/introduction-to-data-analysis-using-microsoft-excel-5ac4</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%2Fxxntqs7ujfjqkbni4jvj.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%2Fxxntqs7ujfjqkbni4jvj.jpg" alt="Data Visualization using Excel" width="640" height="427"&gt;&lt;/a&gt;&lt;br&gt;
Presently, more and more businesses are utilizing data to make decisions as opposed to using strategies like their intuition or speculation. This has been a result of the rise of big data, with companies like Facebook having about &lt;a href="https://sproutsocial.com/insights/facebook-stats-for-marketers/" rel="noopener noreferrer"&gt;3.06 billion active users every month.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When aptly analysed, such data is highly beneficial not only to business owners who optimize their businesses but also to users who get more personalized experiences, among other advantages. Consequently, any new data analyst must select a powerful tool that has a fairly gentle learning curve to analyze complex datasets. Microsoft Excel is one such tool that fits this description and is used by most data analysts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Useful Data Analysis Features in Excel&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Formulas and Functions&lt;/li&gt;
&lt;li&gt;Sorting and Filtering Data&lt;/li&gt;
&lt;li&gt;Logical Functions&lt;/li&gt;
&lt;li&gt;Conditional Formatting and Data Validation&lt;/li&gt;
&lt;li&gt;Excel Tables&lt;/li&gt;
&lt;li&gt;Charts and Graphics&lt;/li&gt;
&lt;li&gt;PivotTables and PivotCharts&lt;/li&gt;
&lt;li&gt;Data Cleaning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Formulas and Functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always starts with an equal sign, a formula is an expression that is used for calculation on data in a worksheet.&lt;/p&gt;

&lt;p&gt;Example: =A1+A2&lt;/p&gt;

&lt;p&gt;A function, on the other hand, is a predefined formula that simplifies complex calculations.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;=SUM(A1:A10)- Calculates the summation&lt;/p&gt;

&lt;p&gt;=AVERAGE(B1:B5)- Calculates the mean&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sorting and Filtering Data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sorting arranges the data into a meaningful order, either in ascending or descending order.&lt;/p&gt;

&lt;p&gt;Filtered data displays only the rows that meet the criteria that you specify and hides rows that you do not want displayed.&lt;/p&gt;

&lt;p&gt;In Excel, under the Home tab, select Sort &amp;amp; Filter to display the sorting options available and the filter option.&lt;/p&gt;

&lt;p&gt;For example, a data analyst has a list of customer orders with columns for “Product” and “Price.” To find the most expensive orders for a specific product, they would first filter the “Product” column to show only the desired item and then sort the “Price” column in descending order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logical Functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Excel offers 4 logical functions, ie, AND, OR, XOR, and NOT. These functions are useful when making more than one comparison or testing multiple conditions instead of a single one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AND- returns true if both arguments satisfy the condition
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;eg. =AND(A1&amp;gt;10,A2&amp;lt;30): the formula returns TRUE if the value in cell A1 is greater than 10 and the value in A2 is less than 30, FALSE otherwise.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OR- returns TRUE if at least one argument is true &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;eg. =OR(A1&amp;gt;=10, B1&amp;lt;10): returns TRUE if A1 is greater than or equal to 10 or B1 is less than 10 or both. If A1 is less than 10 and B1 is greater than 10, then the formula returns FALSE.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;XOR- returns a logical exclusive Or of all arguments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;eg. =XOR(A1&amp;gt;=10, A2&amp;lt;10): returns TRUE if one of either A1 is greater or equal to 10 or A2 is less than 10, returns FALSE otherwise.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NOT- negates the logical value of its argument&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;eg. =NOT(A1&amp;gt;10): returns FALSE if the value in A1 is greater than 10, TRUE otherwise.&lt;/p&gt;

&lt;p&gt;In addition to the above logical functions, Excel provides conditional functions, ie, IF, &lt;a href="https://www.bcti.com/2017/02/06/excel-ifs-and-switch-function-say-goodbye-to-nested-ifs-and-vlookups-on-small-tables/" rel="noopener noreferrer"&gt;IFS, and SWITCH&lt;/a&gt;, that are used to make a decision based on a condition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conditional Formatting and Data Validation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Nested under the Home tab, Conditional formatting is a useful feature to help analysts visually emphasize data and identify trends. For example, to find out the products that generated the highest and lowest revenue, a data analyst would select the “Revenue” column and apply conditional formatting. This highlights top-performing products and underperforming ones in a different colour.&lt;/p&gt;

&lt;p&gt;Data Validation is an equally important feature as it restricts the type of data that can be entered into a cell. For example to data validation rules can be applied to the “Age” column to prevent illogical entries like negative numbers or extremely large numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Excel Tables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using tables offers advantages such as automatic formatting and filtering, structured referencing, range expansion, and better readability.&lt;/p&gt;

&lt;p&gt;To convert data to a table:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the Insert tab after selecting the data range&lt;/li&gt;
&lt;li&gt;Select Table and tick “My table has headers”&lt;/li&gt;
&lt;li&gt;Click OK.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Charts and Graphics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Charts help to visually present data in different forms depending on the variables being represented. When selecting a chart to represent your data, it is important to evaluate which chart would best tell the data story.&lt;/p&gt;

&lt;p&gt;Some of the charts in Excel include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Column chart- compares totals of different categories over time&lt;/li&gt;
&lt;li&gt;Bar chart- compares categories with long labels&lt;/li&gt;
&lt;li&gt;Line chart- shows trends over time&lt;/li&gt;
&lt;li&gt;Pie chart- shows part of the whole&lt;/li&gt;
&lt;li&gt;Area chart- visualizes cumulative changes of multiple variables over time&lt;/li&gt;
&lt;li&gt;Scatter chart- visualizes the relationship between 2 numerical values
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Frequently used in dashboards, these charts are easily generated by selecting the data range and selecting the specific chart needed under the Insert tab.&lt;/p&gt;

&lt;p&gt;Additionally, &lt;strong&gt;sparklines&lt;/strong&gt; are bars that are embedded into a single cell that visualize data trends. Similarly, &lt;strong&gt;data bars&lt;/strong&gt; are a type of conditional formatting that adds colour to cells in a range to indicate how large the cell values are compared to the other values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PivotTables and PivotCharts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PivotTables are a functionality that helps an analyst group and summarize large data sets. One can add or remove values, perform calculations, and filter and sort data sets.&lt;/p&gt;

&lt;p&gt;For example, when working with a large dataset with numerous columns and rows of numerical data, such as traffic data and user demographics. Pivot tables enable the analyst to perform calculations that properly summarize this information, like finding the sums and counts. This enables efficient data analysis, like answering questions like the amount of total website traffic for different categories of users in a certain month.&lt;/p&gt;

&lt;p&gt;In Excel, select the data range and click PivotTable under the Insert tab. Drag variables into either the Rows or Values, depending on the insight being sort. Adding &lt;a href="https://www.simplilearn.com/tutorials/excel-tutorial/slicers-in-excel" rel="noopener noreferrer"&gt;slicers&lt;/a&gt; to the PivotChart adds more interactivity to the visualization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Cleaning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is no secret that the quality of the output of an analyst’s visualization greatly depends on how thoroughly data is preprocessed. With data cleaning being one of the major steps of data preprocessing, it is paramount that great effort is put into ensuring that the dataset is as optimal for use as it can be.&lt;/p&gt;

&lt;p&gt;Some of the cleaning techniques used in Excel include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Removing duplicate rows&lt;/li&gt;
&lt;li&gt;Handling missing values- this can be done by filling a specific value like 0 or filling in the mean(=AVERAGE(A:A) among others.&lt;/li&gt;
&lt;li&gt;Standardizing text eg =LOWER(A1), =UPPER(A1), =TRIM(A1) etc.&lt;/li&gt;
&lt;li&gt;Combining columns eg, combining first name and last name, =A1&amp;amp; “ ”&amp;amp;B1&lt;/li&gt;
&lt;li&gt;Converting the data type eg, numeric fields mistakenly stored as text&lt;/li&gt;
&lt;li&gt;Using the Find and Replace feature&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Mentioned above are the basic features that an individual who is new to data analysis would find useful in Microsoft Excel. Although not an exhaustive list, it suffices to nudge you in the right direction.&lt;/p&gt;

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