<?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: Nimo Mohamed</title>
    <description>The latest articles on DEV Community by Nimo Mohamed (@nimo08).</description>
    <link>https://dev.to/nimo08</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%2F1135845%2F2ff0e0ee-b7e9-4662-a897-bc028725592f.jpg</url>
      <title>DEV Community: Nimo Mohamed</title>
      <link>https://dev.to/nimo08</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nimo08"/>
    <language>en</language>
    <item>
      <title>RateMyReads API</title>
      <dc:creator>Nimo Mohamed</dc:creator>
      <pubDate>Thu, 23 May 2024 10:41:46 +0000</pubDate>
      <link>https://dev.to/nimo08/ratemyreads-api-b8p</link>
      <guid>https://dev.to/nimo08/ratemyreads-api-b8p</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;RateMyReads, a platform dedicated to book enthusiasts, relies on a robust API to facilitate seamless user interaction and efficient data management. This article delves into the development journey of RateMyReads API, outlining the technologies utilized, challenges encountered, and future directions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Description
&lt;/h2&gt;

&lt;p&gt;The RateMyReads API project was a solo endeavor, with the goal of crafting an intuitive platform for users to manage their book preferences and engage with a vibrant community of readers. Spearheaded entirely by me, the API development journey spanned from inception to completion, ensuring every aspect of the platform's functionality was meticulously crafted to deliver an exceptional user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technologies Used
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python: Chosen for its readability and extensive libraries, Python served as the primary programming language.&lt;/li&gt;
&lt;li&gt;Django: Leveraged as a high-level Python web framework, Django accelerated development with its built-in features and adherence to the DRY principle.&lt;/li&gt;
&lt;li&gt;Django Rest Framework (DRF): Complemented Django by simplifying API development, providing tools for serialization, authentication, and authorization.&lt;/li&gt;
&lt;li&gt;Postman: Utilized as a comprehensive testing and debugging tool to ensure the reliability and functionality of RateMyReads API.&lt;/li&gt;
&lt;li&gt;Docker: Employed for containerization, simplifying dependency management and deployment processes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Developments
&lt;/h2&gt;

&lt;p&gt;Throughout the development process, several milestones were achieved:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RESTful API Implementation: A robust API architecture was developed, seamlessly connecting user, book, and comment models for efficient data management.&lt;/li&gt;
&lt;li&gt;User Authentication and Authorization: Robust authentication mechanisms were implemented to ensure secure access to the platform, prioritizing user data privacy.&lt;/li&gt;
&lt;li&gt;Email Notification Integration: An email backend was integrated to enhance user communication, providing confirmation emails upon sign-up for a smooth registration process.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Challenges &amp;amp; Areas of Improvement
&lt;/h2&gt;

&lt;p&gt;While significant progress was made, challenges were encountered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deployment Issues: The learning curve with deployment frameworks posed challenges during deployment, highlighting the need for optimization.&lt;/li&gt;
&lt;li&gt;Areas for Improvement: Future iterations will focus on optimizing the deployment process, enhancing API functionality and security, and improving user experience with additional features.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Findings
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Thorough Deployment Research: Emphasized the importance of mastering deployment procedures for smoother project deployment, prompting further exploration into deployment strategies.&lt;/li&gt;
&lt;li&gt;Continuous Technology Learning: Highlighted the value of staying updated with new technologies for enhanced development processes, inspiring ongoing learning and adaptation.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Optimize Deployment Process: Research and implement deployment strategies to streamline the deployment process and mitigate deployment-related challenges.&lt;/li&gt;
&lt;li&gt;Enhance API Functionality and Security: Continuously improve API functionality and security measures to ensure a seamless and secure user experience.&lt;/li&gt;
&lt;li&gt;Incorporate Additional Features: Gather user feedback to identify and implement additional features that enhance the overall user experience and engagement on the platform.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;The development of RateMyReads API has been an enriching experience, marked by significant achievements and valuable learnings. Despite challenges, I remain committed to refining and expanding the platform to meet user needs effectively and enhance overall functionality and usability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Repository
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/Nimo08/RateMyReads-API"&gt;https://github.com/Nimo08/RateMyReads-API&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>api</category>
      <category>django</category>
      <category>postman</category>
    </item>
    <item>
      <title>Harvest Hex: Cultivate Fun!</title>
      <dc:creator>Nimo Mohamed</dc:creator>
      <pubDate>Fri, 19 Jan 2024 10:16:07 +0000</pubDate>
      <link>https://dev.to/nimo08/harvest-hex-cultivate-fun-2703</link>
      <guid>https://dev.to/nimo08/harvest-hex-cultivate-fun-2703</guid>
      <description>&lt;h2&gt;
  
  
  Purpose of the Project
&lt;/h2&gt;

&lt;p&gt;The purpose of Harvest Hex is to provide a simple and enjoyable 2D runner game experience using the Pygame library. The game offers players the opportunity to navigate a pixelated world set in a forest, controlling a character through obstacles. The design emphasizes retro-style graphics, straightforward gameplay, and a stress-free environment with the option to restart the game upon losing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Timeline
&lt;/h2&gt;

&lt;p&gt;As a sole developer, I took on the roles of designing, coding, and testing the game. The timeline for the project spanned 01/12/2023 to 18/01/2024, with various stages of development and testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Target Audience
&lt;/h2&gt;

&lt;p&gt;Harvest Hex was created for individuals who appreciate retro-style 2D games, enjoy pixelated characters, and seek a relaxing gaming experience. The game is accessible to both gaming enthusiasts and newcomers, aiming to provide a straightforward and enjoyable gameplay session for all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Personal Focus
&lt;/h2&gt;

&lt;p&gt;As a novice in game development, my personal focus during the creation of Harvest Hex was to explore the fundamentals of game design, programming, and the Pygame module. This project served as a learning opportunity to gain hands-on experience in developing a simple yet engaging game. The goal was to create an accessible and enjoyable gaming experience while honing my skills as a game developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Diagrammatic Representation of Harvest Hex Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl6arfw5r347w04oia8n5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl6arfw5r347w04oia8n5.png" alt="Harvest Hex Intro Screen" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Technologies Used
&lt;/h2&gt;

&lt;p&gt;Harvest Hex has been developed using Pygame, a Python module tailored for game development. Pygame provides tools for graphics, sounds and player input, allowing for the easy integration of pixelated characters and backgrounds, contributing to the game’s retro charm. &lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Endless runner gameplay with obstacles and challenges.&lt;/li&gt;
&lt;li&gt;Pixel art style for a visually engaging experience.&lt;/li&gt;
&lt;li&gt;Simple controls for an easy and enjoyable gaming experience.&lt;/li&gt;
&lt;li&gt;Score tracking to encourage competition and improvement.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Challenges Faced
&lt;/h2&gt;

&lt;p&gt;Initially, the aim was to offer users a hassle-free gaming experience with a standalone executable – a one-stop solution for downloading and playing independently. However, as the development progressed, I re-evaluated this goal to enhance the overall user experience. The current implementation necessitates bundling the executable file with the rest of the game assets. While it deviates from the initial plan, this decision prioritizes seamless playability and accessibility.&lt;/p&gt;

&lt;p&gt;In practical terms, this means that to enjoy Harvest Hex, users need to have all the necessary files in one place. While it might differ from the convenience of a standalone executable, it ensures that the game operates smoothly and is readily accessible when all the required components are present. This adjustment allowed for the prioritization of user satisfaction, providing a game that is not only enjoyable but also easy to access and play without complications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Findings
&lt;/h2&gt;

&lt;p&gt;Engaging in game development has been an illuminating journey, unveiling a realm of intricacies within the technical landscape of this craft. The project delved into captivating aspects such as animations, frame rates, and collision detection, unraveling the underlying complexities that contribute to the seamless and immersive gaming experience. These technical interests have not only broadened my understanding but also sparked a newfound intrigue, inspiring further exploration into the nuanced details that shape the world of game development.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the developer
&lt;/h2&gt;

&lt;p&gt;I'm Nimo Mohamed, a passionate enthusiast of all things fantasy, especially when it comes to literature. The development of Harvest Hex has proven to be an enjoyable exploration into the captivating realm of gaming.&lt;/p&gt;

&lt;h2&gt;
  
  
  Harvest Hex Github Link
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/Nimo08/Harvest-Hex"&gt;https://github.com/Nimo08/Harvest-Hex&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Harvest Hex Landing Page
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://harvest-hex.onrender.com/"&gt;https://harvest-hex.onrender.com/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Contact
&lt;/h2&gt;

&lt;p&gt;Let's Connect on Linkedin: &lt;a href="https://www.linkedin.com/in/nimo-mohamed/"&gt;https://www.linkedin.com/in/nimo-mohamed/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>pygame</category>
      <category>gaming</category>
      <category>python</category>
      <category>2dgaming</category>
    </item>
    <item>
      <title>What happens when you type https://www.google.com in your browser and press Enter</title>
      <dc:creator>Nimo Mohamed</dc:creator>
      <pubDate>Thu, 16 Nov 2023 10:48:12 +0000</pubDate>
      <link>https://dev.to/nimo08/what-happens-when-you-type-httpswwwgooglecom-in-your-browser-and-press-enter-moi</link>
      <guid>https://dev.to/nimo08/what-happens-when-you-type-httpswwwgooglecom-in-your-browser-and-press-enter-moi</guid>
      <description>&lt;ul&gt;
&lt;li&gt;If you have watched any heist movie then you know, the wonder always comes from the behind-the-scenes events; all the detailed machinations set in place by the group of thieves that are played out in a grand reveal as every part of their plan falls into place just so.&lt;/li&gt;
&lt;li&gt;When a user types in the URL into any browser of their choice, it takes seconds at most to receive results, the highest of which are the most accurate.&lt;/li&gt;
&lt;li&gt;However, there are a lot of components in play under the hood communicating to allow the user access to the website as well as allowing them to interact with said website. This article aims to explain the processes that occur after pressing Enter.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Domain Name System (DNS)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Google.com is a lot easier to remember than a unique set of characters assigned to google’s domain name.&lt;/li&gt;
&lt;li&gt;The DNS performs the conversion of the domain name typed into the browser into an IP address i.e., the digital equivalent of a postal address which identifies devices across the internet.&lt;/li&gt;
&lt;li&gt;The client computer performs the series of steps below to get ahold of the required IP  address.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The diagram below depicts the communication that occurs when the client computer submits a DNS query to find the matching IP address to the domain name entered by the user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For each step in the diagram, the handover is performed if the current component does not contain the matching IP address.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fta5wnnw7rz7gvd7ivyqk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fta5wnnw7rz7gvd7ivyqk.png" alt="DNS Query Process" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Component Key
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Hosts file &amp;amp; Cache: this is a temporary storage for previously visited IP address that allows the client computer to quickly access the requested website.&lt;/li&gt;
&lt;li&gt; DNS Resolver: acts as an intermediary between the client computer and the other DNS servers&lt;/li&gt;
&lt;li&gt;Root Name Server: main reference in the DNS hierarchy; provides directions to the correct TLD nameserver.&lt;/li&gt;
&lt;li&gt;TLD Name server: stores information about domain names i.e. the last section of a domain name such as .com; for google.com the .com TLD name server leads to the location of the matching IP address in the final server; authoritative nameserver&lt;/li&gt;
&lt;li&gt;Authoritative Name server: contains information related to domain names&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  TCP/IP (Transmission Control Protocol/Internet Protocol)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This refers to a suite of communications protocols used to interconnect network devices on the internet or any private network.&lt;/li&gt;
&lt;li&gt;Computers use agreed-upon sets of rules i.e., protocols to communicate; when the same protocol is used, communication between devices is seamless, as opposed to the chaos that would occur if multiple protocols are used simultaneously.&lt;/li&gt;
&lt;li&gt;Earlier on in the article, we touched on IP addresses and the part they play in allowing devices across the internet to communicate, TCP is the postman to IP’s postal address that enables the recipient to receive mail or the sender to send mail.&lt;/li&gt;
&lt;li&gt;Information cannot be sent in one go using the above protocols, as this leads to potential loss of certain sections, therefore TCP/IP divides messages into packets to be sent separately and reassembled on the receiving end.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TCP/IP Layers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;There are 4 layers involved in this process as explained below&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Data Link layer: deals with the physical aspect of sending the packers i.e., media such as Ethernet cables, wireless networks etc&lt;/li&gt;
&lt;li&gt;Internet layer: controls the movement of packets around the network&lt;/li&gt;
&lt;li&gt;Transport layer: provides a reliable connection between the 2 devices essentially ensuring the receiving device has gotten hold of the all the packets &lt;/li&gt;
&lt;li&gt;Application layer: this represents the applications that the user interacts with e.g. email&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;If you have heard that using public WiFi is not the safest option, that is because this form of communication is not private, thereby making the possible private data being sent vulnerable to access by unauthorized parties.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Firewalls
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Historically firewalls referred to literal walls intended to contain fire from spreading to other buildings, this form of usage is close to the technological use of firewalls i.e., control of network traffic by selectively allowing or blocking data packets to pass through.&lt;/li&gt;
&lt;li&gt; Firewalls enhance network security by intercepting malicious data packets and can be used with added DNS-based filtering to perform content filtering to deny access to unwanted URLs.&lt;/li&gt;
&lt;li&gt;There are different types of firewalls namely: proxy firewalls, stateful firewalls, next-gen firewalls among others.&lt;/li&gt;
&lt;li&gt;They can be deployed in different methods i.e., hardware-based, software-based or cloud firewalls.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  HTTPS/SSL
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When a user accesses a site on a browser, there are certain sites that have a padlock icon appearing next to the URL; this means that the site being accessed is secure.&lt;/li&gt;
&lt;li&gt;HTTP is a protocol widely used for communication between browsers and web servers; HTTPS is the version of HTTP that has been secured by the Secure Sockets Layer (SSL) which encrypts the data being sent between a website and a browser in the user’s computer.&lt;/li&gt;
&lt;li&gt;When a HTTPS connection to a webpage is requested, an exchange occurs between the website which sends its SSL certificate to the browser containing a public key to begin the secure session; this initiates an SSL handshake that encrypts communication between the browser and the website.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Load Balancer
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In the quest for information retrieval across the internet, the user computer will encounter a load balancer which acts as a distributor of traffic to servers that contain the required information.&lt;/li&gt;
&lt;li&gt;Load balancers rely on algorithms that dictate the distribution of traffic such as round-robin method whereby an authoritative nameserver returns the IP addresses of different servers in the server farm one by one.&lt;/li&gt;
&lt;li&gt;Other algorithms such as weighted round-robin involve assignment of different weights to each server based on their priority or capacity.&lt;/li&gt;
&lt;li&gt;Load balancers are essentially the bridge between the user computer and the servers containing the requested data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Web Server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This server component is responsible for managing HTTP requests and responses, for a website, it accesses the source code and returns static content i.e. the HTML webpage of the website. Nginx is an example of a widely used web server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Application Server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Provides the web server with the dynamic content of the website i.e., the business logic such as adding or updating information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a schema illustrating the flow of the request created when you type in a URL in your browser and press Enter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkte9n703vjkbvmh86ing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkte9n703vjkbvmh86ing.png" alt="Flow of the request" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.hostinger.com/tutorials/what-is-dns"&gt;https://www.hostinger.com/tutorials/what-is-dns&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.avast.com/c-what-is-tcp-ip#"&gt;https://www.avast.com/c-what-is-tcp-ip#&lt;/a&gt;&lt;br&gt;
&lt;a href="https://nordlayer.com/learn/firewall/what-is-firewall/"&gt;https://nordlayer.com/learn/firewall/what-is-firewall/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.instantssl.com/http-vs-https"&gt;https://www.instantssl.com/http-vs-https&lt;/a&gt;&lt;br&gt;
&lt;a href="https://aws.amazon.com/what-is/load-balancing/"&gt;https://aws.amazon.com/what-is/load-balancing/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Web_server"&gt;https://en.wikipedia.org/wiki/Web_server&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Introduction to Bash Scripting</title>
      <dc:creator>Nimo Mohamed</dc:creator>
      <pubDate>Mon, 04 Sep 2023 12:14:13 +0000</pubDate>
      <link>https://dev.to/nimo08/introduction-to-bash-scripting-3cf8</link>
      <guid>https://dev.to/nimo08/introduction-to-bash-scripting-3cf8</guid>
      <description>&lt;p&gt;Bash scripts are computer programs consisting of a series of commands that may be used in the command-line environment. They are commonly used for automating repetitive tasks in Linux systems. &lt;/p&gt;

&lt;h2&gt;
  
  
  Variable Assignment
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The syntax below is used when assigning values to variables in Bash.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;variable&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;value
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$variable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The variable can be accessed in the code by prefixing the variable name with a '$' e.g. $variable as illustrated above.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;There are two types of variables in Bash.&lt;/li&gt;
&lt;li&gt;Global variables: accessible anywhere in the script, regardless of scope, by default, every variable we create in Bash is global.&lt;/li&gt;
&lt;li&gt;Local variables: confined to the section of code or function in which they are declared, they are created using the local keyword.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Difference between global and local variables.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nv"&gt;GLOBAL_VAR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"This is a global variable"&lt;/span&gt;
&lt;span class="k"&gt;function &lt;/span&gt;example &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GLOBAL_VAR&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="c"&gt;# outputs: This is a global variable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!usr/bin/env bash&lt;/span&gt;
&lt;span class="k"&gt;function &lt;/span&gt;&lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;LOCAL_VAR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"This is a local variable"&lt;/span&gt;
     &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$LOCAL_VAR&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="c"&gt;# outputs: This is a local variable&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$LOCAL_VAR&lt;/span&gt; &lt;span class="c"&gt;# outputs nothing&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Looping in Bash
&lt;/h2&gt;

&lt;p&gt;There are three types of loops used in Bash: for loop, while loop and until loop. These loops have varying syntax but can carry out similar tasks when implemented in a Bash script.&lt;/p&gt;

&lt;h2&gt;
  
  
  for loop
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Allows for specification of a list of values.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;NAME &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="k"&gt;in &lt;/span&gt;LIST &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;COMMANDS&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;NAME represents the variable name; often denoted as ‘i’, LIST can be a list of words, strings, numbers etc, and COMMANDS represent any operating system commands, program or shell statement.&lt;/li&gt;
&lt;li&gt;The loop will terminate once the NAME has taken on every value from LIST and no items are left in LIST.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;1..5&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;do
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  while loop
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Allows for repetitive execution of a list of commands, as long as the command controlling the while loop is true.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;while &lt;/span&gt;CONTROL-COMMAND&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;CONSEQUENT-COMMANDS&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;CONTROL-COMMAND can represent any commands that will exit on success or failure.&lt;/li&gt;
&lt;li&gt;The CONSEQUENT-COMMANDS can be any program or script.&lt;/li&gt;
&lt;li&gt;When the CONTROL-COMMAND fails, i.e., is no longer true the loop exits and the done statement is executed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="nt"&gt;-le&lt;/span&gt; 10 &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"While loop"&lt;/span&gt;
    &lt;span class="o"&gt;((&lt;/span&gt; i +&lt;span class="o"&gt;=&lt;/span&gt; 1&lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  until loop
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Allows for repetitive execution of a list of commands as long as the TEST-COMMAND is false, once it succeeds, the loop terminates.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;until &lt;/span&gt;TEST-COMMAND&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;CONSEQUENT-COMMANDS&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;TEST-COMMAND can be any command that can exit on success or failure, CONSEQUENT-COMMANDS can represent any script or Linux command.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;until&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 10 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Bash Scripting"&lt;/span&gt;
    &lt;span class="o"&gt;((&lt;/span&gt; i +&lt;span class="o"&gt;=&lt;/span&gt; 1&lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_01.html"&gt;https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_01.html&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Introduction to Sets in Python</title>
      <dc:creator>Nimo Mohamed</dc:creator>
      <pubDate>Sat, 19 Aug 2023 10:40:09 +0000</pubDate>
      <link>https://dev.to/nimo08/introduction-to-sets-in-python-3lh7</link>
      <guid>https://dev.to/nimo08/introduction-to-sets-in-python-3lh7</guid>
      <description>&lt;p&gt;Data structures are used to organize data for efficient access when needed.&lt;br&gt;
They are a vital part of programming languages and in Python they include: lists, dictionaries,sets and tuples. This article provides a brief overview of the set data structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Sets?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;These are unordered collections with no duplicate elements, they can be created using curly braces ({}) or the set() function. &lt;/li&gt;
&lt;li&gt;Creating empty sets is only possible through the set() function, as the {} will create an empty dictionary, which is a different data structure altogether.&lt;/li&gt;
&lt;li&gt;Sets are mutable and therefore elements can be added or removed.&lt;/li&gt;
&lt;li&gt;Sets are used for membership testing i.e., checking whether a specific element is present in the sequence, elimination of duplicate entries as well as mathematical operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Creation of a set
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Using set() function
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Using curly braces
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Red&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Yellow&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Blue&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;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;my_set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="nc"&gt;set&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Modifying a set
&lt;/h2&gt;

&lt;p&gt;The mutability of sets allows for the addition or removal of elements within a set, this is demonstrated below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding elements
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;67&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_set&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;67&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Removing elements
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_set&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Mathematical operations in sets
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Union: set of all the elements of both sets, without duplicates, uses the ‘|’ operator or the union() method
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,}&lt;/span&gt; 
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;9&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;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&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="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&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;11&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;union&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&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;11&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Intersection: set of all common elements of both the sets, uses the ‘&amp;amp;’ operator or the intersection() method
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,}&lt;/span&gt; 
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;9&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;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&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="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;intersection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Difference: set of all elements in the first set that are not present in the second set, uses the ‘-’ operator or the difference() method
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,}&lt;/span&gt; 
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;9&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;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&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="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&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="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;difference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Symmetric difference: set of all elements that are either in the first set or the second set, but not in both, uses the ‘^’ operator or the symmetric_difference() method
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,}&lt;/span&gt; 
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;9&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;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&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="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&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="mi"&gt;9&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;11&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;symmetric_difference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&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="mi"&gt;9&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;11&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.python.org/3/tutorial/datastructures.html"&gt;https://docs.python.org/3/tutorial/datastructures.html&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>set</category>
      <category>python</category>
      <category>datastructures</category>
      <category>programming</category>
    </item>
    <item>
      <title>Python: Imports and modules</title>
      <dc:creator>Nimo Mohamed</dc:creator>
      <pubDate>Wed, 09 Aug 2023 08:32:36 +0000</pubDate>
      <link>https://dev.to/nimo08/python-imports-and-modules-4jai</link>
      <guid>https://dev.to/nimo08/python-imports-and-modules-4jai</guid>
      <description>&lt;p&gt;When writing scripts in Python, some definitions prove to be useful in different scripts; instead of rewriting these definitions in several files, importing modules can make this process less cumbersome.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a module?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A module is a file containing Python definitions and statements, the specific file name is simply suffixed by .py&lt;/li&gt;
&lt;li&gt;Importing a module in Python allows you to access the functions, classes, variables, and other objects defined within that module for use within your Python script. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What are the contents of a module?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python modules contain various objects such as functions, variables among others.&lt;/li&gt;
&lt;li&gt;For example: we have module named calc; within the calc.py file we have 4 function definitions for mathematical operations i.e., add, sub, multiply, divide.&lt;/li&gt;
&lt;li&gt;We can import the calc module into a script where we want to perform these mathematical operations instead of redefining them again within the script.&lt;/li&gt;
&lt;li&gt;Modules contain executable statements as well, which are used to initialize the module and are run only the first time the module name is encountered in an import statement.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to import modules
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;import 'module': this allows access to the entire module from the script.&lt;/li&gt;
&lt;li&gt;from 'module' import 'object': using the ‘from’ keyword allows you to access specific objects within the module i.e. from math import pi; this imports the pi variable of the math module.&lt;/li&gt;
&lt;li&gt;from 'module' import *: using the * wildcard allows access to all the names within the module except those starting with an ‘_’; this is not recommended as it introduces an unknown set of names into the interpreter, possibly concealing some parts that you have already defined.&lt;/li&gt;
&lt;li&gt;python3 -m 'module' 'file_name': modules can be imported in the command-line as well; the -m represents the module, we then specify the module name, and the name of the file in which we want to use the module. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Module search path
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When a module is imported e.g. calc, the interpreter first searches for a built in module with the name calc, the module names are listed in sys.builtin_module_names; if the name is not found, it proceeds to search for the calc.py in a list of directories given by the variable sys.path.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.python.org/3/tutorial/modules.html"&gt;https://docs.python.org/3/tutorial/modules.html&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>modules</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
