<?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: Mark Gatere</title>
    <description>The latest articles on DEV Community by Mark Gatere (@gateremark).</description>
    <link>https://dev.to/gateremark</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%2F809881%2F186b0498-5ac0-4b1e-aa37-bf653cdfcc6e.jpg</url>
      <title>DEV Community: Mark Gatere</title>
      <link>https://dev.to/gateremark</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gateremark"/>
    <language>en</language>
    <item>
      <title>Register Today 🔥</title>
      <dc:creator>Mark Gatere</dc:creator>
      <pubDate>Thu, 26 Feb 2026 11:22:02 +0000</pubDate>
      <link>https://dev.to/gateremark/-54gc</link>
      <guid>https://dev.to/gateremark/-54gc</guid>
      <description>&lt;p&gt;

&lt;/p&gt;
&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/azure/the-javascript-ai-build-a-thon-season-2-starts-march-2-1e92" class="crayons-story__hidden-navigation-link"&gt;The JavaScript AI Build-a-thon Season 2 starts March 2!&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;
          &lt;a class="crayons-logo crayons-logo--l" href="/azure"&gt;
            &lt;img alt="Microsoft Azure logo" 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%2Forganization%2Fprofile_image%2F512%2F64ce0b82-730d-4ca0-8359-2c21513a0063.jpg" class="crayons-logo__image"&gt;
          &lt;/a&gt;

          &lt;a href="/juliamuiruri4" class="crayons-avatar  crayons-avatar--s absolute -right-2 -bottom-2 border-solid border-2 border-base-inverted  "&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%2Fuser%2Fprofile_image%2F750460%2F7c440b0b-5edc-408f-a3b0-68aefd52c95a.jpg" alt="juliamuiruri4 profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/juliamuiruri4" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Julia Muiruri
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Julia Muiruri
                
              
              &lt;div id="story-author-preview-content-3281120" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/juliamuiruri4" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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%2Fuser%2Fprofile_image%2F750460%2F7c440b0b-5edc-408f-a3b0-68aefd52c95a.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Julia Muiruri&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

            &lt;span&gt;
              &lt;span class="crayons-story__tertiary fw-normal"&gt; for &lt;/span&gt;&lt;a href="/azure" class="crayons-story__secondary fw-medium"&gt;Microsoft Azure&lt;/a&gt;
            &lt;/span&gt;
          &lt;/div&gt;
          &lt;a href="https://dev.to/azure/the-javascript-ai-build-a-thon-season-2-starts-march-2-1e92" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Feb 25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/azure/the-javascript-ai-build-a-thon-season-2-starts-march-2-1e92" id="article-link-3281120"&gt;
          The JavaScript AI Build-a-thon Season 2 starts March 2!
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/typescript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;typescript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/langchain"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;langchain&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/azure/the-javascript-ai-build-a-thon-season-2-starts-march-2-1e92" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;10&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/azure/the-javascript-ai-build-a-thon-season-2-starts-march-2-1e92#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              1&lt;span class="hidden s:inline"&gt; comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;




</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>langchain</category>
      <category>ai</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Mark Gatere</dc:creator>
      <pubDate>Tue, 11 Nov 2025 20:49:17 +0000</pubDate>
      <link>https://dev.to/gateremark/-1nin</link>
      <guid>https://dev.to/gateremark/-1nin</guid>
      <description>&lt;p&gt;

&lt;/p&gt;
&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/igornosatov_15/why-your-deep-neural-network-fails-at-layer-50-and-how-resnet-fixes-it-3c4f" class="crayons-story__hidden-navigation-link"&gt;🔥 Why Your Deep Neural Network Fails at Layer 50 (And How ResNet Fixes It)&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/igornosatov_15" class="crayons-avatar  crayons-avatar--l  "&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%2Fuser%2Fprofile_image%2F3501283%2F8c3fb29a-86ef-4f7b-91ac-155767409f5f.jpg" alt="igornosatov_15 profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/igornosatov_15" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Igor Nosatov
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Igor Nosatov
                
              
              &lt;div id="story-author-preview-content-3013236" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/igornosatov_15" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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%2Fuser%2Fprofile_image%2F3501283%2F8c3fb29a-86ef-4f7b-91ac-155767409f5f.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Igor Nosatov&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/igornosatov_15/why-your-deep-neural-network-fails-at-layer-50-and-how-resnet-fixes-it-3c4f" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Nov 11 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/igornosatov_15/why-your-deep-neural-network-fails-at-layer-50-and-how-resnet-fixes-it-3c4f" id="article-link-3013236"&gt;
          🔥 Why Your Deep Neural Network Fails at Layer 50 (And How ResNet Fixes It)
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/python"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;python&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/pytorch"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;pytorch&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/machinelearning"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;machinelearning&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/igornosatov_15/why-your-deep-neural-network-fails-at-layer-50-and-how-resnet-fixes-it-3c4f" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;5&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/igornosatov_15/why-your-deep-neural-network-fails-at-layer-50-and-how-resnet-fixes-it-3c4f#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            5 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;




</description>
      <category>ai</category>
      <category>python</category>
      <category>pytorch</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>AWS 101: Your Easy Start to Amazon Web Services</title>
      <dc:creator>Mark Gatere</dc:creator>
      <pubDate>Thu, 11 Apr 2024 21:16:04 +0000</pubDate>
      <link>https://dev.to/gateremark/aws-101-your-easy-start-to-amazon-web-services-37km</link>
      <guid>https://dev.to/gateremark/aws-101-your-easy-start-to-amazon-web-services-37km</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I am excited to walk with you, step by step, in this AWS Series where we will cover everything AWS from the word go, to building our applications on the cloud... and this being the first article in this series, I can't wait for your feedback.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Set? Buckle up and let's kick off 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Cloud Computing?
&lt;/h2&gt;

&lt;p&gt;To understand what cloud computing is, let us first understand what a &lt;a href="https://en.wikipedia.org/wiki/Server_(computing)"&gt;server&lt;/a&gt; is and what it comprises of.&lt;/p&gt;




&lt;p&gt;A server is a powerful computer that provides data, services, or functionality to other computers, known as clients, over a network. In essence, servers host and share resources that clients can access. There are many types of servers, including &lt;a href="https://en.wikipedia.org/wiki/Web_server"&gt;web servers&lt;/a&gt;, &lt;a href="https://www.cloudflare.com/learning/email-security/what-is-a-mail-server/"&gt;mail servers&lt;/a&gt;, and &lt;a href="https://en.wikipedia.org/wiki/File_server"&gt;file servers&lt;/a&gt;. Each type performs a specific function. For example, a web server hosts websites and makes them available to users on the internet. When you type a URL into your web browser, you’re actually sending a request to the site’s web server.&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%2Fiw9ht0zi4qbuzd6ffwe1.jpg" 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%2Fiw9ht0zi4qbuzd6ffwe1.jpg" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above is an image of how a &lt;a href="https://en.wikipedia.org/wiki/Server_room"&gt;server room&lt;/a&gt; would look like. In server rooms, there are cables, computer servers, cabinets, routers and networking switches etc. which normally take up a lot of space. Some challenges of having physical servers / server rooms include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Paying for the space where the servers are located.&lt;/li&gt;
&lt;li&gt;Paying for power supply, cooling and maintenance.&lt;/li&gt;
&lt;li&gt;Adding and replacing hardware takes time.&lt;/li&gt;
&lt;li&gt;Scaling is limited since the more your product / company grows, the more servers you need which requires more space.&lt;/li&gt;
&lt;li&gt;Hiring of a 24/7 team to monitor the infrastructure.&lt;/li&gt;
&lt;li&gt;How to deal with disasters? (earthquake, power shut down, fire etc.)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;On the other hand, &lt;a href="https://en.wikipedia.org/wiki/Cloud_computing"&gt;cloud computing&lt;/a&gt; is like "servers on the internet"; a server that can be accessed from anywhere. In traditional computing, we set up physical servers &lt;em&gt;(like in the server room image above)&lt;/em&gt; to run our applications and store data. Cloud computing is now like having a similar server but a virtual one that still includes the software and networking capabilities, making accessing and storing data over the internet possible. &lt;br&gt;
With cloud computing, these servers are owned and managed by a &lt;a href="https://www.techtarget.com/searchitchannel/definition/cloud-service-provider-cloud-provider"&gt;cloud service provider&lt;/a&gt;, like &lt;a href="https://aws.amazon.com/"&gt;Amazon Web Services (AWS)&lt;/a&gt; - &lt;em&gt;covered in this blog series&lt;/em&gt;, &lt;a href="https://cloud.google.com/"&gt;Google Cloud&lt;/a&gt;, &lt;a href="https://portal.azure.com/"&gt;Microsoft Azure&lt;/a&gt; and many others. These servers can be accessed and used over the internet to store data, run applications, or even run artificial intelligence services. The cloud provider, on the other hand, takes care of all the maintenance, upgrades, and security, allowing us to focus only on using the services and building our applications / products rather than managing the infrastructure.&lt;/p&gt;




&lt;p&gt;Cloud computing therefore is, the &lt;strong&gt;on-demand delivery&lt;/strong&gt; of compute power, database storage, application, and other IT resources through a cloud service provider with pay-as-you-go pricing. This means that you will only pay for the service you are using and only the resources you will be using hence you can provision exactly the right type and size of computing resources you need.&lt;br&gt;
Additionally, as mentioned above, in cloud computing, you can access as many resources as you need e.g. accessing servers, storage, databases, application services etc. from anywhere, and almost instantly.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Amazon Web Services owns and maintains the network-connected hardware required for these application services, while you provision and use what you need via a web application.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In present digital age, most companies now have their server rooms in the cloud, eliminating the need for space, power supply, cooling, maintenance etc. which results in significant cost savings. Additionally, they don't have to hire a team to monitor the infrastructure because the cloud provider handles all the maintenance, upgrades, and security of the cloud. It’s like having your own tech team, but without the extra cost.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Did you know that you have actually been using the cloud, without even knowing? Tools like Gmail, which is an E-mail cloud service, where you ONLY pay for your emails stored (no infrastructure, etc.), &lt;a href="https://www.dropbox.com"&gt;Dropbox&lt;/a&gt;, &lt;a href="https://drive.google.com"&gt;Google Drive&lt;/a&gt;, &lt;a href="https://www.icloud.com"&gt;iCloud&lt;/a&gt; which are cloud storage services, and even &lt;a href="https://www.netflix.com/"&gt;Netflix&lt;/a&gt;, which is actually built entirely on AWS and provides you a cloud service, which is to get video on-demand. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These cloud services are however very different from AWS, but in this series, we will learn what goes behind these services and how AWS can help us build these kind of cloud services.&lt;/p&gt;




&lt;h4&gt;
  
  
  The Deployment Models of the Cloud
&lt;/h4&gt;

&lt;p&gt;In our cloud computing introduction, let us go one step further and discuss the different kinds of clouds. There are 3 different kinds of clouds out there:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Private Cloud - This is a cloud service used by a single organization, and not exposed to the public. This means that you have complete control over it since it meets specific business needs. An example of a Private Cloud provider is &lt;a href="https://www.rackspace.com/"&gt;rackspace&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Public Cloud - As the name goes, this is a cloud service owned and operated by a third-party cloud service provider and delivered over the Internet, hence can be accessed and used by the public. The three famous Public Cloud providers are: &lt;a href="https://aws.amazon.com/"&gt;Amazon Web Services (AWS)&lt;/a&gt;, &lt;a href="https://cloud.google.com/"&gt;Google Cloud&lt;/a&gt;, and &lt;a href="https://portal.azure.com/"&gt;Microsoft Azure&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hybrid Cloud - This is an approach where one can keep some servers on premises and extend some capabilities to the cloud. This means that we will have a hybrid of our own infrastructure and the cloud. In this approach, we will have control over sensitive assets in our private infrastructure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h4&gt;
  
  
  The Characteristics of Cloud Computing
&lt;/h4&gt;

&lt;p&gt;Another important thing we need to discuss are the characteristics of cloud computing. There are 5 characteristics of cloud computing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On-demand self service - This means that users can provision resources and use them without any human interaction from the service provider.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Broad network access - This means that the resources are available over the network and can be accessed by diverse client platforms.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multi-tenancy and resource pooling - This means that multiple customers can share the same infrastructure and applications on the cloud while still having security and privacy and all serviced from the same physical resources - They're going to share this entire data center of the cloud.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rapid elasticity and scalability - This means that we can automatically and quickly acquire and dispose resources when needed and we can also quickly and easily scale based on demand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Measured service - This means that the usage is measured, and we are going to pay exactly for what we have used.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h4&gt;
  
  
  Advantages of Cloud Computing
&lt;/h4&gt;

&lt;p&gt;In the introduction section above, we have mentioned a number of advantages of using cloud computing as compared to having physical servers and in this section, let us explore further and understand the six main advantages of cloud computing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Trade capital expense (CAPEX) for operational expense (OPEX) - This means that you don't own the hardware and you are going to pay on-demand hence reducing the Total Cost of Ownership (TCO) &amp;amp; Operational Expense (OPEX). This is like you are renting the service from the cloud provider.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Benefit from massive economies of scale - This means that, since a lot of customers are using the cloud platforms e.g. AWS, then the prices will be reduced by AWS over time because AWS will be more efficient at running due to its large scale.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stop guessing capacity - Initially, we had to plan and buy servers in advance and hope that they would meet the capacity, but now we can actually scale automatically based on the actual measured usage for our application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increase speed and agility - We have increased speed and agility hence we can create, operate and do stuff right away.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stop spending money running and maintaining data centers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go global in minutes - by leverage the Cloud provider's e.g. AWS' global infrastructure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h4&gt;
  
  
  Problems solved by the Cloud
&lt;/h4&gt;

&lt;p&gt;From our advantages above of using cloud computing, let us now discuss the problems we have solved:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt; where we can change resource types when needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost-Effectiveness&lt;/strong&gt; - Pay as you go, for what you use.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability&lt;/strong&gt; where we can accommodate larger loads by making hardware stronger or adding additional nodes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Elasticity&lt;/strong&gt; which is the ability to scale out and scale in when needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;High-availability and fault-tolerance&lt;/strong&gt; because we don't really on the one data center, but on the fleet of data centers all around the world.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Agility&lt;/strong&gt; meaning that we can rapidly develop, test and launch software applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  Types of Cloud Computing
&lt;/h4&gt;

&lt;p&gt;The final topic we will discuss before we get into AWS cloud platform are the different &lt;a href="https://aws.amazon.com/types-of-cloud-computing/"&gt;types of cloud computing&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure as a Service (IaaS)&lt;/strong&gt; - This type provides building blocks for cloud IT; providing services such as networking, computers, and data storage space in its raw form. This type of cloud computing provides the highest level of flexibility and can easily be paralleled with traditional on-premises IT as migration is taking place.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples: Amazon EC2 (on AWS), GCP, Azure, Rackspace, Digital Ocean, Linode etc.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Platform as a Service (PaaS)&lt;/strong&gt; - This type removes the need for an organization to manage the underlying infrastructure hence one can just focus on the deployment and management of their applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples: Elastic Beanstalk (on AWS), Heroku, Google App Engine (GCP), Windows Azure (Microsoft) etc.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Software as a Service (SaaS)&lt;/strong&gt; - This type provides one with a completed product that is run and managed by the service provider. In most cases, people referring to Software as a Service are referring to end-user applications. In this type, you do not have to think about how the service is maintained or how the underlying infrastructure is managed; you only need to think about how you will use that particular piece of software. A good example is the email service where you can send and receive email without having to manage feature additions to the email product or maintain the servers and operating systems that the email program is running on.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples: Many of the AWS services (ex: Rekognition for Machine Learning), Google Apps (Gmail, Google Drive, ...), Dropbox, Zoom etc.&lt;/p&gt;

&lt;p&gt;The image below shows the best comparison between the on-premises server, IaaS, Paas, and SaaS:&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%2Futti4e8m90r7pa7xxgb9.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%2Futti4e8m90r7pa7xxgb9.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  AWS Cloud Overview
&lt;/h2&gt;

&lt;h4&gt;
  
  
  The History
&lt;/h4&gt;

&lt;p&gt;The concept of the cloud computing &lt;a href="https://en.wikipedia.org/wiki/History_of_cloud_computing"&gt;traces its roots back to 1993&lt;/a&gt; but we won't start our discussion from that far. In &lt;strong&gt;2002&lt;/strong&gt;, Amazon established its subsidiary Amazon Web Services, which allowed developers to build applications independently. This was after they realized that the IT departments could be externalized. In &lt;strong&gt;2004&lt;/strong&gt;, AWS launched their first offering publicly, which was SQS. In &lt;strong&gt;2006&lt;/strong&gt;, AWS expanded their offering and they relaunched with the availability of SQS, S3 and EC2. In the same year, Google launched Google Docs, a SaaS model to edit and save documents online. In &lt;strong&gt;2007&lt;/strong&gt;, AWS expanded in Europe and has been expanding globally to-date with very many applications and services running on AWS.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;According to &lt;a href="https://www.gartner.com/en/documents/3989743"&gt;Gartner Magic Quadrant&lt;/a&gt;, a platform that ranks the world’s top cloud companies in its new Magic Quadrant for Strategic Cloud Platform Services report, &lt;a href="https://aws.amazon.com/blogs/aws/aws-named-as-a-leader-in-the-2022-gartner-cloud-infrastructure-platform-services-cips-magic-quadrant-for-the-12th-consecutive-year/"&gt;AWS was named as a leader in the 2022 Gartner Cloud Infrastructure &amp;amp; Platform Services (CIPS) Magic Quadrant for the 12th consecutive year&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  AWS Cloud Use Cases
&lt;/h4&gt;

&lt;p&gt;AWS enables you to build sophisticated, scalable applications which are applicable to a diverse set of industries.&lt;br&gt;
Uses cases can include transferring your enterprise IT or using the cloud as a backup and storage or doing some big data analytics. One can also host a website or create a backend for your mobile and your social applications. We can as well use AWS and have your entire gaming servers running on the cloud.&lt;/p&gt;




&lt;h4&gt;
  
  
  AWS Global Infrastructure
&lt;/h4&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%2F8i55qcaez2a4guxvcoe0.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%2F8i55qcaez2a4guxvcoe0.png" alt="Image description" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS is global and in this section, we are going to learn a bit more specifics about how it works. In AWS, we have, AWS Regions, AWS Availability Zones, AWS Local Zones, AWS Data Centers, and AWS Edge Locations / Points of Presence.&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%2F9n57dko7w73pg8niq628.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%2F9n57dko7w73pg8niq628.png" alt="Image description" width="800" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://infrastructure.aws/"&gt;More on AWS Infrastructure&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Regions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first important concept in AWS is the &lt;em&gt;Regions&lt;/em&gt;. AWS has regions all around the world (as we can see in the image above) and they have names like us-east-1, eu-west-3 … A region is a cluster of data centers located in different locations and at the time of this writing, AWS has launched &lt;a href="https://aws.amazon.com/about-aws/global-infrastructure/"&gt;33 regions globally&lt;/a&gt;. &lt;br&gt;
When we use AWS services, most services are region-scoped meaning that they are going to be linked and scoped to a specific region which means that if we use a service in one region and we try to use it in another region, it will be like a new time of using the service.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;How to choose an AWS Region?&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
Assuming that you need to launch a new application, where should you do it?&lt;br&gt;
Factors to consider:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Compliance with data governance and legal requirements - Data never leaves a region without your explicit permission.&lt;/li&gt;
&lt;li&gt;Proximity to customers - "Where are most of your customers / the consumers of your product?" - Leads to reduced latency.&lt;/li&gt;
&lt;li&gt;Available services within a Region - Not all regions have all services. New services and new features aren’t available in every Region hence when leveraging a service with your application, you need to make sure that the region you're deploying into is available and does have that service. &lt;a href="https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services"&gt;Learn more on the services offered by AWS per region&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Pricing - Pricing varies region to region and is transparent in the service pricing page.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;AWS Availability Zones&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each region has many availability zones (usually a min of 3 and a max of 6). Each availability zone (AZ) is one or more discrete data centers with redundant power, networking, and connectivity and they are separate from each other, so that they’re isolated from disasters.&lt;/p&gt;

&lt;p&gt;E.g. AWS Region Sydney: ap-southeast-2 has 3 availability zones: ap-southeast-2a, ap-southeast-2b and ap-southeast-2c&lt;/p&gt;

&lt;p&gt;Availability zones are connected with high bandwidth and ultra-low latency networking and when they are linked all together, they form a &lt;strong&gt;Region&lt;/strong&gt;. At the time of this writing, AWS has 105 Availability Zones within 33 geographic regions, with announced plans for 18 more Availability Zones and six more AWS Regions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Local Zones&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AWS Local Zones allow you to use select AWS services, like compute and storage services, closer to more end-users, providing them very low latency access to the applications running locally. &lt;br&gt;
They are also connected to the parent region via Amazon’s very high bandwidth private network, giving applications running in AWS Local Zones fast, secure, and seamless access to the rest of AWS services.&lt;br&gt;
AWS Local Zones have their own connection to the internet and support AWS Direct Connect, so resources created in the Local Zone can serve local end-users with very low latency communications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Points of Presence (Edge Locations)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will cover more details on the AWS Points of Presence (PoPs) but just to mention, AWS POPs are endpoints for AWS that are used for caching content and function as a Content Delivery Network (CDN) where requests are routed to the nearest edge location automatically, allowing for low latency no matter where the end user is located.&lt;/p&gt;




&lt;h2&gt;
  
  
  AWS Console
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Creating an AWS Account
&lt;/h4&gt;

&lt;p&gt;The first thing to do is to create an AWS Account by heading over to &lt;a href="https://aws.amazon.com/"&gt;aws.amazon.com&lt;/a&gt; and clicking the "Sign In to the Console" button.&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%2Fz3j2ht87v5utpbv8e95g.gif" 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%2Fz3j2ht87v5utpbv8e95g.gif" alt="Image description" width="600" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On getting to the AWS Sign in page, since we have no existing AWS account, we will click the "Create a new AWS account" button at the bottom of the screen.&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%2Flgzyb34h61hgns55du8j.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%2Flgzyb34h61hgns55du8j.png" alt="Image description" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is how the AWS Sign up page looks like:&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%2F411mptd6877o3boq4nbg.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%2F411mptd6877o3boq4nbg.png" alt="Image description" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After successfully creating an AWS account following the instructions, you will be redirected to the console page where you can start working with the AWS services. The Console Home page will look like the image below but not exactly similar more so for them that will have created their AWS accounts for the first time.&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%2Fnwdj1zjiou2suw3jmhnk.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%2Fnwdj1zjiou2suw3jmhnk.png" alt="Image description" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  Console and Services Tour
&lt;/h4&gt;

&lt;p&gt;In the top right corner, we have the regions section with &lt;strong&gt;US East (N. Virginia): us-east-1&lt;/strong&gt; region selected.&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%2Fhih33fnkqvfm1hagq24r.gif" 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%2Fhih33fnkqvfm1hagq24r.gif" alt="Image description" width="600" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we mentioned previously, it is advisable to choose / select a region that is geographically closer to you to give you / your customers the lowest amount of latency.&lt;br&gt;
On the Console Home we can also see a section with the "Recently visited" services and is empty for them that have created the account for the first time. On the Console Home, we also have other sections such as "AWS Health", "Cost and usage", "Build a solution" ...etc.&lt;br&gt;
Next, on our top left corner, we have the "Services" button where on clicking the button, we get to see all the AWS services organized by category and also in alphabetical order.&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%2F0sorlnzvrr3dtzsxc6p8.gif" 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%2F0sorlnzvrr3dtzsxc6p8.gif" alt="Image description" width="600" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the top there is also a search bar where you can search for a service and get results for all the matches of the service or of your search including features where the searched term has been mentioned, in documentation, market place, Blogs etc.&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%2F92em9lwj3x6ffprcgblb.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%2F92em9lwj3x6ffprcgblb.png" alt="Image description" width="800" height="74"&gt;&lt;/a&gt;&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%2F88jdbfw8caes7k5skg9c.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%2F88jdbfw8caes7k5skg9c.png" alt="Image description" width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's also worth mentioning again that &lt;strong&gt;not all regions have all services&lt;/strong&gt; and an addition to that, is that some services like the &lt;strong&gt;Route 53&lt;/strong&gt; are global services hence one cannot select a specific region for them while others have specific regions where they are available.&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%2F3lco0t46winnyas2zys8.gif" 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%2F3lco0t46winnyas2zys8.gif" alt="Image description" width="600" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services"&gt;Learn more on the services offered by AWS per region&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  Shared Responsibility Model
&lt;/h4&gt;

&lt;p&gt;As we wrap up the first article, I want to mention that Security and Compliance is a shared responsibility between AWS and the customer (cloud user). AWS responsibility is “Security of the Cloud” which means that AWS is responsible for protecting the infrastructure that runs all of the services offered in the AWS Cloud, while the Customer responsibility is “Security in the Cloud” which means that the customer's responsibility will be determined by the AWS Cloud services that they select. This determines the amount of configuration work the customer must perform as part of their security responsibilities.&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%2F98pycoangl614v9be1l5.jpg" 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%2F98pycoangl614v9be1l5.jpg" alt="Image description" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/compliance/shared-responsibility-model/"&gt;Learn more about the AWS Shared Responsibility Model&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;That's it for the introduction to AWS - AWS 101: Your Easy Start to Amazon Web Services. 🥳&lt;br&gt;
In this article, we have discussed what cloud computing is, a number of nitty gritty AWS concepts and terms, and how to get started with AWS by creating an account. We also had a sneak peak on the AWS Console Home and different sections on the console.&lt;br&gt;
In the next article, we will kick off immediately with different AWS services and the first concept being understanding what &lt;strong&gt;IAM (Identity and Access Management)&lt;/strong&gt; is and different IAM policies.&lt;/p&gt;

&lt;p&gt;See you then. 🚀&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>cloudcomputing</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Say hello to Big (O)h!</title>
      <dc:creator>Mark Gatere</dc:creator>
      <pubDate>Tue, 06 Sep 2022 22:58:50 +0000</pubDate>
      <link>https://dev.to/gateremark/say-hello-to-big-oh-5a28</link>
      <guid>https://dev.to/gateremark/say-hello-to-big-oh-5a28</guid>
      <description>&lt;p&gt;&lt;code&gt;Oh&lt;/code&gt; or rather &lt;code&gt;O&lt;/code&gt;, chosen by Bachmann to stand for Ordnung, meaning the &lt;strong&gt;Order of approximation&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Wait, what is this guy saying?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Helloooo and welcome back! Do not mind my curtain-raiser for this article for what we are going to be covering is super easy. It is known as &lt;strong&gt;The Big O notation&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;According to &lt;a href="https://en.wikipedia.org/wiki/Big_O_notation"&gt;wikipedia&lt;/a&gt;, the Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity and characterizes functions according to their growth rates where different functions with the same growth rate may be represented using the same O notation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ooh oh! Not again. 😅&lt;br&gt;
In simple terms, (as used in Data Structures), the Big O notation is a way of comparing two sets of code, super simple, right? &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%2F02pn45f2ykpxzeuw8xmf.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%2F02pn45f2ykpxzeuw8xmf.png" alt="Comparison of two set of codes" width="252" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assuming Code 1 and Code 2 accomplish exactly the same thing, how would you compare one to the other? Code 1 might be more readable while Code 2 can be more concise. Big O is a way of comparing Code 1 and Code 2 mathematically on their efficiency as they run. &lt;br&gt;
Assuming too that you have a stopwatch, and we run Code 1 and start the stopwatch and the code runs for 15 seconds, then we reset the stopwatch and run Code 2 together with the stopwatch and it runs for 1 minute, based on this, we can say Code 1 is more efficient than Code 2. This is called &lt;strong&gt;Time Complexity&lt;/strong&gt;.&lt;br&gt;
The thing about &lt;strong&gt;Time Complexity&lt;/strong&gt; that is interesting is that it is not measured in time. This is because if you took the same code and run it on a computer that runs twice as fast, it will complete twice as fast which does not make the code better but rather the computer is better. &lt;strong&gt;Time Complexity&lt;/strong&gt; is therefore measured in the number of operations that it takes to complete something, a topic we will look deeper into with more examples in the course of the article.&lt;/p&gt;

&lt;p&gt;In addition to Time Complexity, we also measure &lt;strong&gt;Space Complexity&lt;/strong&gt;. Despite Code 1 running super fast comparatively, it possibly might be taking a lot of memory space and maybe Code 2, despite taking more time in execution, may be taking less space in memory. If preserving memory space is your most important priority and you don't mind having some extra Time Complexity, maybe Code 2 is better. &lt;br&gt;
It is therefore best to understand both concepts to be able to address the most important priority when given an "interview question" on either of the concepts either being a program that runs super fast or either one that conserves memory space.&lt;/p&gt;



&lt;p&gt;When dealing with Time Complexity and Space Complexity, there are three greek letters one will interact with: &lt;code&gt;Ω (omega), Θ (theta), and O (omicron)&lt;/code&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assuming you have a list with seven items, and you are to build a for loop to iterate through it to find a specific number:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Assuming we are looking for number '1', number '4' and number '7' in the list below using a for loop:

[1, 2, 3, 4, 5, 6, 7]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To get the number '1', we are going to find it in one operation, hence it's our &lt;strong&gt;&lt;em&gt;best-case scenario&lt;/em&gt;&lt;/strong&gt; but when we are looking for the number '7', we have to iterate through the entire list to find it, hence it's our &lt;strong&gt;&lt;em&gt;worst-case scenario&lt;/em&gt;&lt;/strong&gt;. If looking for the number '4', it's our &lt;strong&gt;&lt;em&gt;average-case scenario&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
When one is talking about the 'best-case scenario', that is referred to as &lt;code&gt;Ω&lt;/code&gt; (omega), while talking about the 'average-case scenario', that's &lt;code&gt;Θ&lt;/code&gt; (theta) and while talking about the worst-case scenario, that's &lt;code&gt;O&lt;/code&gt; (omicron) which is the Big (0) since when measuring Big (o), we are always measuring the Worst case.&lt;br&gt;
&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Technically when talking about Big O, we are talking mainly of the &lt;code&gt;worst-case scenario&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To start with, we will mainly focus on the Time complexity.&lt;br&gt;
We are gonna discuss different types of Big O notations as printed on my 'sweatshirt' below😅​ &lt;em&gt;(Never Mind! haha)&lt;/em&gt;:&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%2Fb0fev8jqnp4zzdez11u4.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%2Fb0fev8jqnp4zzdez11u4.png" alt="My sweatshirt" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below are images with some characteristics we will discuss for each notation on their complexities:&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%2Fz5t23y83y2yymaelcir0.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%2Fz5t23y83y2yymaelcir0.PNG" alt="Big-o Complexity chart" width="800" height="546"&gt;&lt;/a&gt;&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%2F0fd3r62s5pmyabmqqkwi.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%2F0fd3r62s5pmyabmqqkwi.PNG" alt="Common Data Structure Operations" width="800" height="468"&gt;&lt;/a&gt;&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%2Fd1iwyhd5c9sgieykja6o.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%2Fd1iwyhd5c9sgieykja6o.PNG" alt="Array Sorting Algorithms" width="800" height="648"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.bigocheatsheet.com/"&gt;Link to the above Big (O) cheatsheet&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Disclaimer: I have used Python code to explain each complexity.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;O(n)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is one of the easiest Big O to explain. Let's use some code to explain this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def print_items(n):
    for i in range(n):
        print(i)
print_items(10)

0
1
2
3
4
5
6
7
8
9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above &lt;code&gt;print_items&lt;/code&gt; function is an example of something that is O(n). &lt;code&gt;n&lt;/code&gt; stands for the number of operations. We passed in the function number 'n' and it ran n times or 'n' operations. &lt;em&gt;Example&lt;/em&gt; When we use 10 for 'n' in our function above, we output 10 items (0 - 9) which means the number of operations 'n' is directly proportional to the number of items / elements we output.&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%2Fb3uj0wcjlcdtinvs7a5b.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%2Fb3uj0wcjlcdtinvs7a5b.png" alt="Image description" width="800" height="820"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Visualizing this on a graph:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   |                              *
   |                    O(n) *
 T |                    *
 i |               *
 m |          *
 e |     *
   |_*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
                input size
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;O(n) is always proportional hence it will always be a straight line.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drop Constants&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are a few ways in which we can simplify the Big O notation. The first one is known as the &lt;strong&gt;&lt;u&gt;drop constant&lt;/u&gt;&lt;/strong&gt;.&lt;br&gt;
Using our previous example: &lt;code&gt;print_items function&lt;/code&gt;, we are gonna add a second identical &lt;code&gt;for loop&lt;/code&gt; below the original one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def print_items(n):
    for i in range(n):
        print(i)

    for j in range(n):
        print(j)
print_items(10)

0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above operation ran &lt;code&gt;n + n&lt;/code&gt; times / &lt;code&gt;2n&lt;/code&gt; number of operations which we write as O(2n) but we can simplify this by dropping the constant &lt;code&gt;2&lt;/code&gt; and writing it as O(n). We can therefore drop all constants, eg. O(10n), O(100n), O(10000n) == O(n).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O(n^2)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Adding a loop in another loop (nested for loop) using our previous example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def print_items(n):
    for i in range(n):
       for j in range(n):
          print(i, j)
print_items(10)

0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
2 0
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
3 0
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
4 0
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
5 0
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
6 0
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
7 0
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
8 0
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 8
8 9
9 0
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function runs &lt;code&gt;n * n&lt;/code&gt; == n^2 hence we get the O(n^2). By adding an extra for loop and &lt;em&gt;taking the function deeper&lt;/em&gt; (&lt;em&gt;my apologies, the output will be a bit longer but will easily help you to understand how this works out&lt;/em&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def print_items(n):
   for i in range(n):
      for j in range(n):
         for k in range(n):
            print(i, j, k)
print_items(10)
0 0 0
0 0 1
0 0 2
0 0 3
0 0 4
0 0 5
0 0 6
0 0 7
0 0 8
0 0 9
0 1 0
0 1 1
0 1 2
0 1 3
0 1 4
0 1 5
0 1 6
0 1 7
0 1 8
0 1 9
0 2 0
0 2 1
0 2 2
0 2 3
0 2 4
0 2 5
0 2 6
0 2 7
0 2 8
0 2 9
0 3 0
0 3 1
0 3 2
0 3 3
0 3 4
0 3 5
0 3 6
0 3 7
0 3 8
0 3 9
0 4 0
0 4 1
0 4 2
0 4 3
0 4 4
0 4 5
0 4 6
0 4 7
0 4 8
0 4 9
0 5 0
0 5 1
0 5 2
0 5 3
0 5 4
0 5 5
0 5 6
0 5 7
0 5 8
0 5 9
0 6 0
0 6 1
0 6 2
0 6 3
0 6 4
0 6 5
0 6 6
0 6 7
0 6 8
0 6 9
0 7 0
0 7 1
0 7 2
0 7 3
0 7 4
0 7 5
0 7 6
0 7 7
0 7 8
0 7 9
0 8 0
0 8 1
0 8 2
0 8 3
0 8 4
0 8 5
0 8 6
0 8 7
0 8 8
0 8 9
0 9 0
0 9 1
0 9 2
0 9 3
0 9 4
0 9 5
0 9 6
0 9 7
0 9 8
0 9 9
1 0 0
1 0 1
1 0 2
1 0 3
1 0 4
1 0 5
1 0 6
1 0 7
1 0 8
1 0 9
1 1 0
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 1 6
1 1 7
1 1 8
1 1 9
1 2 0
1 2 1
1 2 2
1 2 3
1 2 4
1 2 5
1 2 6
1 2 7
1 2 8
1 2 9
1 3 0
1 3 1
1 3 2
1 3 3
1 3 4
1 3 5
1 3 6
1 3 7
1 3 8
1 3 9
1 4 0
1 4 1
1 4 2
1 4 3
1 4 4
1 4 5
1 4 6
1 4 7
1 4 8
1 4 9
1 5 0
1 5 1
1 5 2
1 5 3
1 5 4
1 5 5
1 5 6
1 5 7
1 5 8
1 5 9
1 6 0
1 6 1
1 6 2
1 6 3
1 6 4
1 6 5
1 6 6
1 6 7
1 6 8
1 6 9
1 7 0
1 7 1
1 7 2
1 7 3
1 7 4
1 7 5
1 7 6
1 7 7
1 7 8
1 7 9
1 8 0
1 8 1
1 8 2
1 8 3
1 8 4
1 8 5
1 8 6
1 8 7
1 8 8
1 8 9
1 9 0
1 9 1
1 9 2
1 9 3
1 9 4
1 9 5
1 9 6
1 9 7
1 9 8
1 9 9
2 0 0
2 0 1
2 0 2
2 0 3
2 0 4
2 0 5
2 0 6
2 0 7
2 0 8
2 0 9
2 1 0
2 1 1
2 1 2
2 1 3
2 1 4
2 1 5
2 1 6
2 1 7
2 1 8
2 1 9
2 2 0
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 3 0
2 3 1
2 3 2
2 3 3
2 3 4
2 3 5
2 3 6
2 3 7
2 3 8
2 3 9
2 4 0
2 4 1
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
2 4 7
2 4 8
2 4 9
2 5 0
2 5 1
2 5 2
2 5 3
2 5 4
2 5 5
2 5 6
2 5 7
2 5 8
2 5 9
2 6 0
2 6 1
2 6 2
2 6 3
2 6 4
2 6 5
2 6 6
2 6 7
2 6 8
2 6 9
2 7 0
2 7 1
2 7 2
2 7 3
2 7 4
2 7 5
2 7 6
2 7 7
2 7 8
2 7 9
2 8 0
2 8 1
2 8 2
2 8 3
2 8 4
2 8 5
2 8 6
2 8 7
2 8 8
2 8 9
2 9 0
2 9 1
2 9 2
2 9 3
2 9 4
2 9 5
2 9 6
2 9 7
2 9 8
2 9 9
3 0 0
3 0 1
3 0 2
3 0 3
3 0 4
3 0 5
3 0 6
3 0 7
3 0 8
3 0 9
3 1 0
3 1 1
3 1 2
3 1 3
3 1 4
3 1 5
3 1 6
3 1 7
3 1 8
3 1 9
3 2 0
3 2 1
3 2 2
3 2 3
3 2 4
3 2 5
3 2 6
3 2 7
3 2 8
3 2 9
3 3 0
3 3 1
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
3 3 8
3 3 9
3 4 0
3 4 1
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 5 0
3 5 1
3 5 2
3 5 3
3 5 4
3 5 5
3 5 6
3 5 7
3 5 8
3 5 9
3 6 0
3 6 1
3 6 2
3 6 3
3 6 4
3 6 5
3 6 6
3 6 7
3 6 8
3 6 9
3 7 0
3 7 1
3 7 2
3 7 3
3 7 4
3 7 5
3 7 6
3 7 7
3 7 8
3 7 9
3 8 0
3 8 1
3 8 2
3 8 3
3 8 4
3 8 5
3 8 6
3 8 7
3 8 8
3 8 9
3 9 0
3 9 1
3 9 2
3 9 3
3 9 4
3 9 5
3 9 6
3 9 7
3 9 8
3 9 9
4 0 0
4 0 1
4 0 2
4 0 3
4 0 4
4 0 5
4 0 6
4 0 7
4 0 8
4 0 9
4 1 0
4 1 1
4 1 2
4 1 3
4 1 4
4 1 5
4 1 6
4 1 7
4 1 8
4 1 9
4 2 0
4 2 1
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 2 7
4 2 8
4 2 9
4 3 0
4 3 1
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 4 0
4 4 1
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
4 5 0
4 5 1
4 5 2
4 5 3
4 5 4
4 5 5
4 5 6
4 5 7
4 5 8
4 5 9
4 6 0
4 6 1
4 6 2
4 6 3
4 6 4
4 6 5
4 6 6
4 6 7
4 6 8
4 6 9
4 7 0
4 7 1
4 7 2
4 7 3
4 7 4
4 7 5
4 7 6
4 7 7
4 7 8
4 7 9
4 8 0
4 8 1
4 8 2
4 8 3
4 8 4
4 8 5
4 8 6
4 8 7
4 8 8
4 8 9
4 9 0
4 9 1
4 9 2
4 9 3
4 9 4
4 9 5
4 9 6
4 9 7
4 9 8
4 9 9
5 0 0
5 0 1
5 0 2
5 0 3
5 0 4
5 0 5
5 0 6
5 0 7
5 0 8
5 0 9
5 1 0
5 1 1
5 1 2
5 1 3
5 1 4
5 1 5
5 1 6
5 1 7
5 1 8
5 1 9
5 2 0
5 2 1
5 2 2
5 2 3
5 2 4
5 2 5
5 2 6
5 2 7
5 2 8
5 2 9
5 3 0
5 3 1
5 3 2
5 3 3
5 3 4
5 3 5
5 3 6
5 3 7
5 3 8
5 3 9
5 4 0
5 4 1
5 4 2
5 4 3
5 4 4
5 4 5
5 4 6
5 4 7
5 4 8
5 4 9
5 5 0
5 5 1
5 5 2
5 5 3
5 5 4
5 5 5
5 5 6
5 5 7
5 5 8
5 5 9
5 6 0
5 6 1
5 6 2
5 6 3
5 6 4
5 6 5
5 6 6
5 6 7
5 6 8
5 6 9
5 7 0
5 7 1
5 7 2
5 7 3
5 7 4
5 7 5
5 7 6
5 7 7
5 7 8
5 7 9
5 8 0
5 8 1
5 8 2
5 8 3
5 8 4
5 8 5
5 8 6
5 8 7
5 8 8
5 8 9
5 9 0
5 9 1
5 9 2
5 9 3
5 9 4
5 9 5
5 9 6
5 9 7
5 9 8
5 9 9
6 0 0
6 0 1
6 0 2
6 0 3
6 0 4
6 0 5
6 0 6
6 0 7
6 0 8
6 0 9
6 1 0
6 1 1
6 1 2
6 1 3
6 1 4
6 1 5
6 1 6
6 1 7
6 1 8
6 1 9
6 2 0
6 2 1
6 2 2
6 2 3
6 2 4
6 2 5
6 2 6
6 2 7
6 2 8
6 2 9
6 3 0
6 3 1
6 3 2
6 3 3
6 3 4
6 3 5
6 3 6
6 3 7
6 3 8
6 3 9
6 4 0
6 4 1
6 4 2
6 4 3
6 4 4
6 4 5
6 4 6
6 4 7
6 4 8
6 4 9
6 5 0
6 5 1
6 5 2
6 5 3
6 5 4
6 5 5
6 5 6
6 5 7
6 5 8
6 5 9
6 6 0
6 6 1
6 6 2
6 6 3
6 6 4
6 6 5
6 6 6
6 6 7
6 6 8
6 6 9
6 7 0
6 7 1
6 7 2
6 7 3
6 7 4
6 7 5
6 7 6
6 7 7
6 7 8
6 7 9
6 8 0
6 8 1
6 8 2
6 8 3
6 8 4
6 8 5
6 8 6
6 8 7
6 8 8
6 8 9
6 9 0
6 9 1
6 9 2
6 9 3
6 9 4
6 9 5
6 9 6
6 9 7
6 9 8
6 9 9
7 0 0
7 0 1
7 0 2
7 0 3
7 0 4
7 0 5
7 0 6
7 0 7
7 0 8
7 0 9
7 1 0
7 1 1
7 1 2
7 1 3
7 1 4
7 1 5
7 1 6
7 1 7
7 1 8
7 1 9
7 2 0
7 2 1
7 2 2
7 2 3
7 2 4
7 2 5
7 2 6
7 2 7
7 2 8
7 2 9
7 3 0
7 3 1
7 3 2
7 3 3
7 3 4
7 3 5
7 3 6
7 3 7
7 3 8
7 3 9
7 4 0
7 4 1
7 4 2
7 4 3
7 4 4
7 4 5
7 4 6
7 4 7
7 4 8
7 4 9
7 5 0
7 5 1
7 5 2
7 5 3
7 5 4
7 5 5
7 5 6
7 5 7
7 5 8
7 5 9
7 6 0
7 6 1
7 6 2
7 6 3
7 6 4
7 6 5
7 6 6
7 6 7
7 6 8
7 6 9
7 7 0
7 7 1
7 7 2
7 7 3
7 7 4
7 7 5
7 7 6
7 7 7
7 7 8
7 7 9
7 8 0
7 8 1
7 8 2
7 8 3
7 8 4
7 8 5
7 8 6
7 8 7
7 8 8
7 8 9
7 9 0
7 9 1
7 9 2
7 9 3
7 9 4
7 9 5
7 9 6
7 9 7
7 9 8
7 9 9
8 0 0
8 0 1
8 0 2
8 0 3
8 0 4
8 0 5
8 0 6
8 0 7
8 0 8
8 0 9
8 1 0
8 1 1
8 1 2
8 1 3
8 1 4
8 1 5
8 1 6
8 1 7
8 1 8
8 1 9
8 2 0
8 2 1
8 2 2
8 2 3
8 2 4
8 2 5
8 2 6
8 2 7
8 2 8
8 2 9
8 3 0
8 3 1
8 3 2
8 3 3
8 3 4
8 3 5
8 3 6
8 3 7
8 3 8
8 3 9
8 4 0
8 4 1
8 4 2
8 4 3
8 4 4
8 4 5
8 4 6
8 4 7
8 4 8
8 4 9
8 5 0
8 5 1
8 5 2
8 5 3
8 5 4
8 5 5
8 5 6
8 5 7
8 5 8
8 5 9
8 6 0
8 6 1
8 6 2
8 6 3
8 6 4
8 6 5
8 6 6
8 6 7
8 6 8
8 6 9
8 7 0
8 7 1
8 7 2
8 7 3
8 7 4
8 7 5
8 7 6
8 7 7
8 7 8
8 7 9
8 8 0
8 8 1
8 8 2
8 8 3
8 8 4
8 8 5
8 8 6
8 8 7
8 8 8
8 8 9
8 9 0
8 9 1
8 9 2
8 9 3
8 9 4
8 9 5
8 9 6
8 9 7
8 9 8
8 9 9
9 0 0
9 0 1
9 0 2
9 0 3
9 0 4
9 0 5
9 0 6
9 0 7
9 0 8
9 0 9
9 1 0
9 1 1
9 1 2
9 1 3
9 1 4
9 1 5
9 1 6
9 1 7
9 1 8
9 1 9
9 2 0
9 2 1
9 2 2
9 2 3
9 2 4
9 2 5
9 2 6
9 2 7
9 2 8
9 2 9
9 3 0
9 3 1
9 3 2
9 3 3
9 3 4
9 3 5
9 3 6
9 3 7
9 3 8
9 3 9
9 4 0
9 4 1
9 4 2
9 4 3
9 4 4
9 4 5
9 4 6
9 4 7
9 4 8
9 4 9
9 5 0
9 5 1
9 5 2
9 5 3
9 5 4
9 5 5
9 5 6
9 5 7
9 5 8
9 5 9
9 6 0
9 6 1
9 6 2
9 6 3
9 6 4
9 6 5
9 6 6
9 6 7
9 6 8
9 6 9
9 7 0
9 7 1
9 7 2
9 7 3
9 7 4
9 7 5
9 7 6
9 7 7
9 7 8
9 7 9
9 8 0
9 8 1
9 8 2
9 8 3
9 8 4
9 8 5
9 8 6
9 8 7
9 8 8
9 8 9
9 9 0
9 9 1
9 9 2
9 9 3
9 9 4
9 9 5
9 9 6
9 9 7
9 9 8
9 9 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function run &lt;code&gt;n * n * n&lt;/code&gt; times hence it becomes O(n^3) but using &lt;code&gt;drop constants&lt;/code&gt; to simplify this, it can also be written as O(n^2).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Notice that the first and the last elements in the output of the function(s) respectively are: O(n) - 0, 9 || O(n^2) - 00, 99 || O(n^3) - 000, 999.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Visualizing it on a graph:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   |          *                  
   |  O(n^2) *              
 T |        *          
 i |       *     
 m |      *  
 e |    * 
   |_*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
                input size
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;O(n^2) graph is steeper than the O(n) graph. This means that O(n^2) is a lot less efficient than O(n) from a Time Complexity standpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   |          *                  *
   |  O(n^2) *              * 
 T |        *          *
 i |       *      * O(n)
 m |      *   *
 e |    * *
   |_*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
                input size
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Drop Non-Dominants&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The second way to simplify the Big O notation is known as &lt;strong&gt;&lt;u&gt;drop non-dominants&lt;/u&gt;&lt;/strong&gt;.&lt;br&gt;
Using the nested for loop example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def print_items(n):
   for i in range(n):
      for j in range(n):
         print(i, j)
   for k in range(n):
      print(k)
print_items(10)
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
2 0
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
3 0
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
4 0
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
5 0
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
6 0
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
7 0
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
8 0
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 8
8 9
9 0
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 9
0
1
2
3
4
5
6
7
8
9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function ran twice. The first nested loop (i and j) ran O(n^2) while the second single loop (k) ran O(n). Hence the total number of the output is O(n^2) + O(n) which can also be written as O(n^2 + n). &lt;br&gt;
The main thing of 'n' we are concerned about is "what happens when we start having 'n' as a very large number?" eg. when we have 'n' as 100, n^2 == 10000, hence as a percentage of the total number of operations, the stand-alone 'n' will still remain to be 100, which is a very small portion of the number of operations, hence it is insignificant. In the equation O(n^2 + n), 'n^2' is the dominant term while the stand-alone 'n' is the non-dominant, we drop the non-dominant and the notation remains to be O(n^2).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In comparison to other Big Os we have covered, as 'n' gets bigger, the number of operations increases, but with this Big O...:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add_items(n):
   return n + n
add_items(5)
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...there is always a single operation, and an increase to 'n' does not lead to an increase in the number of operations(remains constant). &lt;code&gt;return n + n + n&lt;/code&gt; == O(2) == O(1).&lt;br&gt;
O(1) is also called &lt;strong&gt;constant time&lt;/strong&gt;. This is because as 'n' increases, the number of operations will remain constant.&lt;br&gt;
Visualizing it on a graph:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   |                              
   |                    
 T |                    
 i |               
 m |          
 e |              O(1) 
   |_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_ _ 
                input size
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As 'n' increases, there is no increase in Time Complexity. This makes it the most efficient big(O). &lt;em&gt;Anytime that you can make something O(1), it is as optimal as you can make it&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   |          *                  *
   |  O(n^2) *              * 
 T |        *          *
 i |       *      * O(n)
 m |      *   *
 e |    * *           O(1)
   |_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_ _ _ 
                input size
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;O(log n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In demonstrating and explaining this, we will start with an example.&lt;br&gt;
Assuming we have a list and looking for number '1' 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;[1, 2, 3, 4, 5, 6, 7, 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;The numbers should be sorted&lt;/em&gt;. &lt;br&gt;
What we are going to do is to find the most efficient way of finding the number '1' from the list.&lt;br&gt;
We will first divide the list into half and check whether the number is either in the first half or the second half. We will take the half with the number and do away with the other half. We will continue with the process till we find the number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[1, 2, 3, 4] [5, 6, 7, 8] --- 1 is in the first half
[1, 2] [3, 4] --- 1 is in the first half
[1] [2] --- 1 is in the first half
1 --- We finally remain with the number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then count how many steps we took to find the number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. [1, 2, 3, 4] [5, 6, 7, 8] --- 1 is in the first half
2. [1, 2] [3, 4] --- 1 is in the first half
3. [1] [2] --- 1 is in the first half
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We took 3 steps to find the number from a total of 8 items(numbers).&lt;br&gt;
&lt;code&gt;2^3 = 8&lt;/code&gt; == &lt;code&gt;log2 8 = 3&lt;/code&gt;&lt;br&gt;
8 -- Total items&lt;br&gt;
3 -- Steps taken to arrive to the final number after dividing the number into halves&lt;br&gt;
We can have an example like: &lt;code&gt;log2 1,073,741,824 = 31&lt;/code&gt; meaning that you can divide that number 31 times into halves to get to the final number despite which item you're looking for.&lt;br&gt;
O(log n) is more efficient that O(n) but slightly less in efficiency than O(1).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O(nlog n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a Big(O) used with some sorting algorithms like merge sort and quick sort. This is not an efficient Big(O), however, this is the most efficient that you can make a sorting algorithm, sorting various types of data besides numbers.&lt;/p&gt;



&lt;blockquote&gt;
&lt;p&gt;Different terms for input is a Big(O) concept that interviewers like to as kind of a &lt;em&gt;gotcha&lt;/em&gt; question.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's start with an example having different parameters for the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def print_items(a, b):
    for i in range(a):
        print(i)

    for j in range(b):
        print(j)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When covering O(n), we mentioned &lt;strong&gt;dropping constants&lt;/strong&gt; and hence you might think that because this has two loops in the function, it can be equated to O(2n) == O(n) &lt;strong&gt;WHICH IS WRONG&lt;/strong&gt;.&lt;br&gt;
Being that the function has two parameters, a - 'n1' cannot be equivalent to b - 'n2' hence the Big(O) is &lt;strong&gt;O(a + b)&lt;/strong&gt;.&lt;br&gt;
Similarly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def print_items(a, b):
    for i in range(a):
       for j in range(b):
          print(i, j) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...the Big(O) is &lt;strong&gt;O(a * b)&lt;/strong&gt;.&lt;/p&gt;




&lt;h4&gt;
  
  
  Big(O) of Lists
&lt;/h4&gt;

&lt;p&gt;Assuming we have a list &lt;code&gt;my_list = [11, 2, 23, 7]&lt;/code&gt;:&lt;br&gt;
If we want to append a number 17 at the end, (my_list.append(17)), there will be no re-indexing of the original numbers in the list.&lt;br&gt;
Same case applies when we want to pop the number from the list, (my_list.pop()), no re-indexing of the items will occur. This therefore becomes a Big(O) of &lt;strong&gt;O(1)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However, when we want to pop a number at the index of 0, (my_list.pop(0)), or insert a number at index 0, (my_list.insert(0, 13)), re-indexing of all the items in the list occurs. This therefore becomes a Big(O) of &lt;strong&gt;O(n)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What about inserting items at the middle of the list? (my_list.insert(1, 'Hi'))&lt;br&gt;
Re-indexing of the items at the right of the inserted item occurs. It being at the middle cannot be referred to as O(1/2 n). This is because Big(O) measures worst case and secondly '1/2' is a constant, hence we drop the constant. Therefore the Big(O) of inserting and popping items from the middle of the list is &lt;strong&gt;O(n)&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Looking for the item in a list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When looking for number 7 in the list &lt;code&gt;my_list = [11, 3, 32, 7]&lt;/code&gt;, we will iterate over the entire list till we find 7 in the list hence the Big(O) is &lt;strong&gt;O(n)&lt;/strong&gt;. But when we are looking for a number using an index from the list, (my_list[3]), we will find the number in the index without iterating, hence the Big(O) is &lt;strong&gt;O(1)&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;When we take n to be 100;&lt;br&gt;
O(1)     == 1&lt;br&gt;
O(log n) == 7&lt;br&gt;
O(n)     == 100&lt;br&gt;
O(n^2)   == 10000&lt;/p&gt;

&lt;p&gt;This means that O(n^2) compared to the other 3 is very inefficient. The spread becomes even bigger when 'n' becomes larger.&lt;/p&gt;

&lt;p&gt;When we take n to be 1000;&lt;br&gt;
O(1)     == 1&lt;br&gt;
O(log n) == 10&lt;br&gt;
O(n)     == 1000&lt;br&gt;
O(n^2)   == 1000000&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;Terminologies used to refer to the Big(O)s:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;O(1) - Constant&lt;br&gt;
O(log n) - Divide and Conquer&lt;br&gt;
O(n) - Proportional (will always be a straight line)&lt;br&gt;
O(n^2) - Loop within a loop&lt;/p&gt;

&lt;p&gt;Summing it all up; We can now understand the chart below, that we had seen earlier in the course... however we didn't cover O(n!) and O(2^n) as they are not common and one has to intentionally write bad code to achieve.&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%2Facqlrlvusbgglh7c31ld.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%2Facqlrlvusbgglh7c31ld.png" alt="Big-o Complexity chart" width="800" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Till Next time... Bye bye&lt;/p&gt;

</description>
      <category>programming</category>
      <category>bigonotation</category>
      <category>datastructures</category>
      <category>python</category>
    </item>
    <item>
      <title>Data Structures 101: Introduction to Data Structures and Algorithms.</title>
      <dc:creator>Mark Gatere</dc:creator>
      <pubDate>Mon, 20 Jun 2022 23:53:05 +0000</pubDate>
      <link>https://dev.to/gateremark/data-structures-101-introduction-to-data-structures-and-algorithms-4oib</link>
      <guid>https://dev.to/gateremark/data-structures-101-introduction-to-data-structures-and-algorithms-4oib</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Why do I need to learn Data Structures and Algorithms in the first place? Will I use them in my workspace?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hello and welcome. We are going to demystify the importance of familiarizing oneself with data structures and algorithms and why the interviewers prefer them in the interviews. &lt;br&gt;
Set? Buckle up and let's set off...&lt;/p&gt;




&lt;p&gt;To start off, what is a Data Structure as well as an Algorithm?&lt;br&gt;
From &lt;a href="https://en.wikipedia.org/wiki/Data_structure" rel="noopener noreferrer"&gt;Wikipedia&lt;/a&gt;, a data structure is a data organization, management, and storage format that enables efficient access and modification. In simple terms, a data structure is a way of storing data in an efficient or structured manner. In the real world examples, we have examples like a book rack, kitchen cabinets and shoe racks.&lt;br&gt;
In my &lt;a href="https://dev.to/gateremark/python-from-the-word-go-4h93"&gt;Python from the word ...Go&lt;/a&gt; article, I have covered inbuilt python data structures which comprise: lists, dictionaries, tuples, and sets. Inbuilt data structures mean that they come with ready syntax to be used by the user. In addition to inbuilt data structures, we have user-defined data structures which comprise: array, stack, queue, linked list, tree, graph, and hashmap. This means that the user has to create them from scratch.&lt;br&gt;
We will not go into depths on the inbuilt data structures but can be found explained in depths in the &lt;a href="https://dev.to/gateremark/python-from-the-word-go-4h93"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What then is an algorithm?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An algorithm is a collection of steps to solve a particular problem which can be understood by non-technical people as well. There can be multiple ways and steps to solve a given problem hence there can be multiple algorithms for a specific problem.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why are Data Structures and Algorithms important?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To start off, data structures and algorithms in interviews act as a clear demonstration to the interviewer on your problem-solving skills. &lt;br&gt;
Secondly, data structures refer to the way we organize information on our computers and you can guess that the way we organize information can have a lot of impact on the performance. A good example is a library. Suppose, one wants to have a book on Calculus from a library, to do so, one has to first go to the math section, then to the Calculus section. If these books had not been organized in this manner and just distributed randomly then it would have been really a cumbersome process to find the book. &lt;br&gt;
In addition, an Algorithm is a step-by-step process in solving a given task. They are developed to help perform a task more efficiently by one applying a predefined approach or methodology. If you write code as per your perception and judgement without applying any predefined algorithm, your code will probably be botched up after a certain time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To sum up, they help one write efficient code and solve problems in optimal or near-optimal ways. Without them, one will be reinventing the wheel which is not always successfully.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  Built-in Data Structures
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;List&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lists are data structures used to store data in a sequential manner.&lt;br&gt;
They use square brackets.&lt;br&gt;
Every single element in a list is indexed from index 0.&lt;br&gt;
Negative indexing in lists is also supported where the last item in a list is given a -1 index. This helps access of elements from the last to the first.&lt;br&gt;
Data in lists can be modified.&lt;br&gt;
Example of a list:&lt;/p&gt;

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

sample_list = [3, 5, "hello", True, 4.76]
Output: [3, 5, "hello", True, 4.76]


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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Tuples&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tuples work like lists but data in tuples cannot be modified (immutable).&lt;br&gt;
They use parenthesis/round brackets.&lt;br&gt;
Example of a tuple:&lt;/p&gt;

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

sample_tuple = (1, 3, "Mark")
Output: (1, 3, "Mark")


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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Dictionaries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Data in dictionaries is stored as key-value pairs.&lt;br&gt;
The pairs can be accessed, added, and deleted when needed.&lt;br&gt;
Data is stored in curly braces.&lt;br&gt;
Example:&lt;/p&gt;

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

sample_dict = {"first":"Mark", "Second":"Gatere"}
Output: sample_dict{'first': 'Mark', 'Second': 'Gatere'}


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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Sets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sets, like dictionaries, use curly brackets.&lt;br&gt;
They store a collection of unordered unique elements where each data element must be unique.&lt;br&gt;
Example:&lt;/p&gt;

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

my_set = {1, 2, 3, 3, 4, 5, 5}
Output: {1, 2, 3, 4, 5}


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

&lt;/div&gt;
&lt;h4&gt;
  
  
  User-defined data structures
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Stack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fgwwprax328nzh356iv5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fgwwprax328nzh356iv5m.png" alt="Stack of books"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assuming you have a 'stack' of books, to get a book in the middle of the stack, one has to get the book at the top book first followed by the second book... to the book that the person wants to access. In Stack, this approach is known as &lt;strong&gt;LIFO&lt;/strong&gt; (Last-in First-out).&lt;br&gt;
This means that it is a linear data structure where elements are accessed only from the top position.&lt;br&gt;
In Stack, elements can be pushed, accessed, and popped as required.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fsg2r9z3nwtk7o3mze1my.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fsg2r9z3nwtk7o3mze1my.jpg" alt="Image from geeks for geeks"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

stack = ['first', 'second', 'third']
print(stack)

print()

# pushing elements
stack.append('fourth')
stack.append('fifth')
print(stack)
print()

# printing top
n = len(stack)
print(stack[n-1])
print()

# poping element
stack.pop()
print(stack)

------
(Output)

[‘first’, ‘second’, ‘third’]

[‘first’, ‘second’, ‘third’, ‘fourth’, ‘fifth’]

fifth

[‘first’, ‘second’, ‘third’, ‘fourth’]


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/stack-data-structure/" rel="noopener noreferrer"&gt;More on Stack&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Queue&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fpn3uf3a0zo4zb7k7jz35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fpn3uf3a0zo4zb7k7jz35.png" alt="Queue of people"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unlike Stack, Queue works on a principle known as &lt;strong&gt;FIFO&lt;/strong&gt; (Fist-in First-out).&lt;br&gt;
Queues have both head and tail sections and operations can be performed from both the head and the tail.&lt;br&gt;
This means that data in a queue can be accessed and modified either from both the head and/or the tail.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fs2q7fvmswxoj1n56x42b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fs2q7fvmswxoj1n56x42b.jpg" alt="Image from geeks for geeks"&gt;&lt;/a&gt;&lt;/p&gt;

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

queue = ['first', 'second', 'third']
print(queue)

print()

# pushing elements
queue.append('fourth')
queue.append('fifth')
print(queue)
print()

# printing head
print(queue[0])

# printing tail
n = len(queue)
print(queue[n-1])
print()

# poping element
queue.remove(queue[0])
print(queue)

------
(Output)

[‘first’, ‘second’, ‘third’]

[‘first’, ‘second’, ‘third’, ‘fourth’, ‘fifth’]

first

fifth

[‘second’, ‘third’, ‘fourth’, ‘fifth’]


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/queue-data-structure/" rel="noopener noreferrer"&gt;More on Queue&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tree&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2F7wwrjw8jry3ifbjf26jd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F7wwrjw8jry3ifbjf26jd.jpg" alt="Image from geeks for geeks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A tree is a non-linear but hierarchical data structure where data originates from the &lt;strong&gt;root node&lt;/strong&gt;.&lt;br&gt;
Each node that precedes another node is known as a &lt;strong&gt;parent node&lt;/strong&gt; while that node is referred to as a &lt;strong&gt;child node&lt;/strong&gt;.&lt;br&gt;
The last nodes in a tree are called &lt;strong&gt;leaves&lt;/strong&gt;.&lt;/p&gt;

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

class node:
    def __init__(self, ele):
        self.ele = ele
        self.left = None
        self.right = None


def preorder(self):
    if self:
        print(self.ele)
        preorder(self.left)
        preorder(self.right)


n = node('first')
n.left = node('second')
n.right = node('third')
preorder(n)

------
(Output)

first

second

third


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/binary-tree-data-structure/" rel="noopener noreferrer"&gt;More on Trees&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Graph&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fgxvtafakfmu94e29rifz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fgxvtafakfmu94e29rifz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A Graph is a non-linear data structure which has a structure which is similar to a tree but works differently. It has nodes which are also referred to as vertices and edges which are lines or arcs that connect any two nodes in the graph.&lt;br&gt;
A valid graph structure consists of a finite set of nodes and edges.&lt;br&gt;
An example is the use of &lt;em&gt;Facebook&lt;/em&gt; where everyone is a vertex in the network.&lt;/p&gt;

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

class adjnode:
    def __init__(self, val):
        self.val = val
        self.next = None


class graph:
    def __init__(self, vertices):
        self.v = vertices
        self.ele = [None]*self.v

    def edge(self, src, dest):
        node = adjnode(dest)
        node.next = self.ele[src]
        self.ele[src] = node

        node = adjnode(src)
        node.next = self.ele[dest]
        self.ele[dest] = node

    def __repr__(self):
        for i in range(self.v):
            print("Adjacency list of vertex {}\n head".format(i), end="")
            temp = self.ele[i]
            while temp:
                print(" -&amp;gt; {}".format(temp.val), end="")
                temp = temp.next


g = graph(4)
g.edge(0, 2)
g.edge(1, 3)
g.edge(3, 2)
g.edge(0, 3)
g.__repr__()

------
(Output)

Adjacency list of vertex 0

head -&amp;gt; 3 -&amp;gt; 2

Adjacency list of vertex 1

head -&amp;gt; 3

Adjacency list of vertex 2

head -&amp;gt; 3 -&amp;gt; 0

Adjacency list of vertex 3

head -&amp;gt; 0 -&amp;gt; 2 -&amp;gt; 1


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/graph-data-structure-and-algorithms/" rel="noopener noreferrer"&gt;More on Graphs&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linked List&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fvoij8aeekoz2hevz5fns.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fvoij8aeekoz2hevz5fns.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A linked list is a linear data structure which consists of a sequence of elements that are connected to each other and not stored at contiguous memory locations. The elements in a linked list are linked using pointers.&lt;br&gt;
Python does not have linked lists in its standard library.&lt;/p&gt;

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

llist = ['first', 'second', 'third']
print(llist)

print()

# adding elements
llist.append('fourth')
llist.append('fifth')
llist.insert(3, 'sixth')
print(llist)
print()

llist.remove('second')
print(llist)
print()

------
(Output)

[‘first’, ‘second’, ‘third’]

[‘first’, ‘second’, ‘third’, ‘sixth’, ‘fourth’, ‘fifth’]

[‘first’, ‘third’, ‘sixth’, ‘fourth’, ‘fifth’]


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/data-structures/linked-list/#singlyLinkedList" rel="noopener noreferrer"&gt;More on Linked List&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hashmap&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hash maps are indexed data structures which make use of a hash function to compute the index with a key into an array of slots or buckets.&lt;br&gt;
Its value is mapped to the bucket with a corresponding index.&lt;br&gt;
The key cannot be changed (immutable) and is unique. &lt;br&gt;
In python, dictionaries are examples of hash maps.&lt;/p&gt;

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

def printdict(d):
    for key in d:
        print(key, "-&amp;gt;", d[key])


hm = {0: 'first', 1: 'second', 2: 'third'}
printdict(hm)
print()

hm[3] = 'fourth'
printdict(hm)
print()

hm.popitem()
printdict(hm)

------
(Output)

0 -&amp;gt; first

1 -&amp;gt; second

2 -&amp;gt; third

0 -&amp;gt; first

1 -&amp;gt; second

2 -&amp;gt; third

3 -&amp;gt; fourth

0 -&amp;gt; first

1 -&amp;gt; second

2 -&amp;gt; third


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/hash-map-in-python/" rel="noopener noreferrer"&gt;More on Hashmaps&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;We now have the basics of data structures. Let's meet in the next session where we expound more on data structures and algorithms as we focus on types of algorithms too.&lt;br&gt;
Can't wait to see you...🥳&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>programming</category>
      <category>beginners</category>
      <category>career</category>
    </item>
    <item>
      <title>Python from the word ...Go (Pt2)</title>
      <dc:creator>Mark Gatere</dc:creator>
      <pubDate>Fri, 10 Jun 2022 12:37:07 +0000</pubDate>
      <link>https://dev.to/gateremark/python-from-the-word-go-pt2-31k0</link>
      <guid>https://dev.to/gateremark/python-from-the-word-go-pt2-31k0</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Basics Part2&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Helloooo there! Welcome back!!&lt;br&gt;
Wait, are you new here? Don't worry, I got you covered. Here, we are breaking the flow. Have you checked "Python from the word ...Go" &lt;a href="https://dev.to/gateremark/python-from-the-word-go-4h93"&gt;Basics Part1?&lt;/a&gt; It's an awesome resource to first check out if you are not familiar with Python's variables and data types which comprise a few in-built Python data structures.&lt;br&gt;
They are really gonna come in handy for this section.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Set? Lets' go!!&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;In the &lt;a href="https://dev.to/gateremark/python-from-the-word-go-4h93"&gt;previous module&lt;/a&gt;, we learnt about the fundamental Python data types and also covered some of the terms used when talking about code like variables, statements, expressions, functions, methods ...etc.&lt;br&gt;
Most importantly, we covered how to perform actions on the data types (Both functions and methods for each data type). &lt;br&gt;
Up until now, we were still scratching the surface. Every time we write code, we wrote it line by line and hence our interpreter would go line by line running each code up to the last line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; #do something
&amp;gt;&amp;gt;&amp;gt; #do something
&amp;gt;&amp;gt;&amp;gt; #do something
&amp;gt;&amp;gt;&amp;gt; #do something
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are now going to incorporate the idea of running multiple lines over and over to discover the true power of programming for machines, haha!&lt;br&gt;
Hence, in this section, we gonna talk about the idea of &lt;strong&gt;conditions&lt;/strong&gt; and &lt;strong&gt;conditional logic&lt;/strong&gt;. We gonna discuss more on looping and loops where we can perform actions multiple times over and over.&lt;br&gt;
We are now going to break into a new world where instead of going from line by line in order, we gonna loop over till a condition is met.&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Conditional Logic&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We &lt;a href="https://dev.to/gateremark/python-from-the-word-go-4h93"&gt;previously&lt;/a&gt; covered Boolean variables (True or False). When we come to conditional logic, Booleans are super important.&lt;br&gt;
&lt;em&gt;Example&lt;/em&gt;:&lt;br&gt;
A person(a) wants to purchase a car from a company with specific conditions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The car must be new.&lt;/li&gt;
&lt;li&gt;The car must have a license.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hence for person(a) to purchase the car:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;is_new = True&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;is_licensed = True&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In conditional logic, we use the 'if' keyword.&lt;br&gt;
&lt;code&gt;"If the car is new and licensed, then person(a) can purchase it".&lt;/code&gt;&lt;br&gt;
Then, if any of the conditions in purchasing the car is not met, person(a) cannot purchase the car.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example2&lt;/em&gt;:&lt;br&gt;
Let's assume that for one to get into a specific event, the person has to be old(35 years and above). Create a program to only allow old people to the event.&lt;br&gt;
&lt;code&gt;If is_old = True, "allowed to get into the event."&lt;/code&gt;&lt;br&gt;
For the syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_old = True
&amp;gt;&amp;gt;&amp;gt; if is_old:
&amp;gt;&amp;gt;&amp;gt;   print("You are allowed to get in")
You are allowed to get in

&amp;gt;&amp;gt;&amp;gt; is_old = False
&amp;gt;&amp;gt;&amp;gt; if is_old:
&amp;gt;&amp;gt;&amp;gt;   print("You are allowed to get in")
#nothing will be printed out.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; Any code that comes after the colon in the condition is automatically indented hence run if the condition is True whereas any code that ain't indented after the condition is not under the condition and hence run separately.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_old = True
&amp;gt;&amp;gt;&amp;gt; if is_old:
&amp;gt;&amp;gt;&amp;gt;   print("You are allowed to get in")
&amp;gt;&amp;gt;&amp;gt; print("Hello there")
You are allowed to get in
Hello there

&amp;gt;&amp;gt;&amp;gt; is_old = False
&amp;gt;&amp;gt;&amp;gt; if is_old:
&amp;gt;&amp;gt;&amp;gt;   print("You are allowed to get in")
&amp;gt;&amp;gt;&amp;gt; print("Hello there")
Hello there
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;What if when a condition is not met(False), we want to perform another condition?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is an example:&lt;br&gt;
I leave my house;&lt;br&gt;
If it's cloudy, I bring an umbrella;&lt;br&gt;
otherwise, I bring sunglasses.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We use the keyword &lt;strong&gt;'else'&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using our example of letting people in for the event, we can add:&lt;br&gt;
&lt;code&gt;If is_old = True, "allowed to get into the event.", otherwise if is_old = False, "not allowed to get in",&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;&amp;gt;&amp;gt;&amp;gt; is_old = True
&amp;gt;&amp;gt;&amp;gt; if is_old:
&amp;gt;&amp;gt;&amp;gt;   print("You are allowed to get in")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed in")
You are allowed to get in

&amp;gt;&amp;gt;&amp;gt; is_old = False
&amp;gt;&amp;gt;&amp;gt; if is_old:
&amp;gt;&amp;gt;&amp;gt;   print("You are allowed to get in")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed in")
Not allowed in
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;What if by chance you have more than one condition?&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example:&lt;br&gt;
I'm in a restaurant;&lt;br&gt;
If I want meat, I order steak;&lt;br&gt;
otherwise, If I want Pasta, I order spaghetti and meatballs;&lt;br&gt;
otherwise, I order salad.&lt;/p&gt;

&lt;p&gt;For such cases, we use the 'elif' keyword (else if).&lt;br&gt;
Using a different example.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A person(b) wants to order chicken pizza. If there is no chicken pizza, the person(b) can order beef pizza; otherwise, if there is none, the person(b) can order rice.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; chicken_pizza = True
&amp;gt;&amp;gt;&amp;gt; beef_pizza = True

&amp;gt;&amp;gt;&amp;gt; if chicken_pizza:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me chicken pizza.")
&amp;gt;&amp;gt;&amp;gt; elif beef_pizza:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me beef pizza.")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me rice.")
Serve me chicken pizza.

--------------------------------------------------
&amp;gt;&amp;gt;&amp;gt; chicken_pizza = False
&amp;gt;&amp;gt;&amp;gt; beef_pizza = True

&amp;gt;&amp;gt;&amp;gt; if chicken_pizza:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me chicken pizza.")
&amp;gt;&amp;gt;&amp;gt; elif beef_pizza:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me beef pizza.")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me rice.")
Serve me beef pizza.

--------------------------------------------------
&amp;gt;&amp;gt;&amp;gt; chicken_pizza = False
&amp;gt;&amp;gt;&amp;gt; beef_pizza = False

&amp;gt;&amp;gt;&amp;gt; if chicken_pizza:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me chicken pizza.")
&amp;gt;&amp;gt;&amp;gt; elif beef_pizza:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me beef pizza.")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Serve me rice.")
Serve me rice.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;"For a person to be legalized to drive a car in public, one must have a national identification card and a driving license."&lt;br&gt;
These are two conditions that one must have to avoid being fined by the cops.&lt;br&gt;
To develop such a program, we must have both conditions True hence we can use the keyword 'and' to check whether both conditions are True.&lt;br&gt;
When using 'and' both conditions must be True to execute the condition, if any of them is False, the program will run the 'elif' and 'else' part.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; has_id = True
&amp;gt;&amp;gt;&amp;gt; has_license = True

&amp;gt;&amp;gt;&amp;gt; if has_id and has_license:
&amp;gt;&amp;gt;&amp;gt;   print("Allowed to drive")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed to drive")
Allowed to drive

--------------------------------------------------
&amp;gt;&amp;gt;&amp;gt; has_id = False
&amp;gt;&amp;gt;&amp;gt; has_license = True

&amp;gt;&amp;gt;&amp;gt; if has_id and has_license:
&amp;gt;&amp;gt;&amp;gt;   print("Allowed to drive")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed to drive")
Not allowed to drive

--------------------------------------------------
&amp;gt;&amp;gt;&amp;gt; has_id = True
&amp;gt;&amp;gt;&amp;gt; has_license = False

&amp;gt;&amp;gt;&amp;gt; if has_id and has_license:
&amp;gt;&amp;gt;&amp;gt;   print("Allowed to drive")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed to drive")
Not allowed to drive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Python Indentation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interpreter in python finds meaning in the spacing hence indentation(tabs) and white spaces in python is essential.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Truthy Vs Falsy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In python, whenever there's a value, the interpreter recognizes that as True. Otherwise, when there's a zero(0) or no value, python interpreter recognizes that as False.&lt;br&gt;
These are referred to as Truthy and Falsy values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(bool('hello'))
&amp;gt;&amp;gt;&amp;gt; print(bool(5))
&amp;gt;&amp;gt;&amp;gt; print(bool(''))
&amp;gt;&amp;gt;&amp;gt; print(bool(0))
&amp;gt;&amp;gt;&amp;gt; print(bool(None))
True
True
False
False
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All values are considered "truthy" except the following; which are considered "falsy":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;None&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;False&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;0&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;0.0&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;0j&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Decimal(0)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Fraction(0, 1)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[]&lt;/code&gt; - an empty &lt;code&gt;list&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;{}&lt;/code&gt; - an empty &lt;code&gt;dict&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;()&lt;/code&gt; - an empty &lt;code&gt;tuple&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;''&lt;/code&gt; - an empty &lt;code&gt;str&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;b''&lt;/code&gt; - an empty &lt;code&gt;bytes&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;set()&lt;/code&gt; - an empty &lt;code&gt;set&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;range(0)&lt;/code&gt; - an empty &lt;code&gt;range&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Objects for which:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;obj.__bool__()&lt;/code&gt; returns &lt;code&gt;False&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;obj.__len__()&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; A "truthy" value will satisfy the check performed by &lt;code&gt;if&lt;/code&gt; or &lt;code&gt;while&lt;/code&gt; statements. We use "truthy" and "falsy" to differentiate from the &lt;code&gt;bool&lt;/code&gt; values &lt;code&gt;True&lt;/code&gt; and &lt;code&gt;False&lt;/code&gt;.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; has_id = 'hello'
&amp;gt;&amp;gt;&amp;gt; has_license = 5

&amp;gt;&amp;gt;&amp;gt; if has_id and has_license:
&amp;gt;&amp;gt;&amp;gt;   print("Allowed to drive")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed to drive")
Allowed to drive

--------------------------------------------------
&amp;gt;&amp;gt;&amp;gt; has_id = 'hello'
&amp;gt;&amp;gt;&amp;gt; has_license = 0

&amp;gt;&amp;gt;&amp;gt; if has_id and has_license:
&amp;gt;&amp;gt;&amp;gt;   print("Allowed to drive")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed to drive")
Not allowed to drive

--------------------------------------------------
&amp;gt;&amp;gt;&amp;gt; has_id = None
&amp;gt;&amp;gt;&amp;gt; has_license = True

&amp;gt;&amp;gt;&amp;gt; if has_id and has_license:
&amp;gt;&amp;gt;&amp;gt;   print("Allowed to drive")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed to drive")
Not allowed to drive

--------------------------------------------------
&amp;gt;&amp;gt;&amp;gt; has_id = True
&amp;gt;&amp;gt;&amp;gt; has_license = ''

&amp;gt;&amp;gt;&amp;gt; if has_id and has_license:
&amp;gt;&amp;gt;&amp;gt;   print("Allowed to drive")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Not allowed to drive")
Not allowed to drive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A good though not perfect example on the use of "truthy" and "falsy" application is in forms or in keying in log in credentials.&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%2Ffbtxcl1k3i8rg8cmnqj4.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%2Ffbtxcl1k3i8rg8cmnqj4.png" alt="Image description" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a field is set to as 'a required field', the system expects the field to be "truthy" hence should not be left blank as this will lead to it being assigned "falsy".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ternary Operator (Conditional Expression)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is another way to do conditional logic. This works the same as 'if statements' but can in a way be referred to as a 'shortcut' so can only be used in certain conditional logic.&lt;br&gt;
In this mode, we start with the condition then incorporate the "if statement".&lt;br&gt;
&lt;code&gt;"condition_if_true" if condition else "condition_if_false"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
Let's use an example to determine if a user is your friend (eg. on Facebook whether the user can message you).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_friend = True
&amp;gt;&amp;gt;&amp;gt; can_message = "Message allowed" if is_friend else "not allowed to message"
&amp;gt;&amp;gt;&amp;gt; print(can_message)
Message allowed

&amp;gt;&amp;gt;&amp;gt; is_friend = True
&amp;gt;&amp;gt;&amp;gt; can_message = "Message allowed" if is_friend else "not allowed to message"
&amp;gt;&amp;gt;&amp;gt; print(can_message)
not allowed to message
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Short Circuiting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Previously we saw how to use the 'and' keyword to validate whether both statements are True:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_friend = True
&amp;gt;&amp;gt;&amp;gt; is_user = True
&amp;gt;&amp;gt;&amp;gt; print(is_friend and is_user)
True

&amp;gt;&amp;gt;&amp;gt; is_friend = True
&amp;gt;&amp;gt;&amp;gt; is_user = False
&amp;gt;&amp;gt;&amp;gt; print(is_friend and is_user)
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In short circuiting, the interpreter ignores one part of the condition(despite it being false) and returns either True or False.&lt;br&gt;
Example, using the 'or' keyword, if the first part of the condition is True the interpreter returns True without checking the second part.&lt;br&gt;
When we use the 'and' keyword, when the the first part of the statement is False, the interpreter ignores(short circuits) the second part and returns False.&lt;br&gt;
An example using the 'or' keyword:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_friend = True
&amp;gt;&amp;gt;&amp;gt; is_user = False
&amp;gt;&amp;gt;&amp;gt; print(is_friend or is_user)
True

&amp;gt;&amp;gt;&amp;gt; is_friend = True
&amp;gt;&amp;gt;&amp;gt; is_user = True
&amp;gt;&amp;gt;&amp;gt; print(is_friend or is_user)
True

&amp;gt;&amp;gt;&amp;gt; is_friend = False
&amp;gt;&amp;gt;&amp;gt; is_user = True
&amp;gt;&amp;gt;&amp;gt; if is_friend or is_user:
&amp;gt;&amp;gt;&amp;gt;   print("Best friends forever")
Best friends forever

&amp;gt;&amp;gt;&amp;gt; is_friend = False
&amp;gt;&amp;gt;&amp;gt; is_user = True
&amp;gt;&amp;gt;&amp;gt; if False or is_user:
&amp;gt;&amp;gt;&amp;gt;   print("Best friends forever")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Never friends")
Best friends forever

&amp;gt;&amp;gt;&amp;gt; is_friend = True
&amp;gt;&amp;gt;&amp;gt; is_user = False
&amp;gt;&amp;gt;&amp;gt; if False or is_user:
&amp;gt;&amp;gt;&amp;gt;   print("Best friends forever")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Never friends")
Never friends

&amp;gt;&amp;gt;&amp;gt; if True or True:
&amp;gt;&amp;gt;&amp;gt;   print("Best friends forever")
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;   print("Never friends")
Best friends forever
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Logical Operators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We have looked at a few logical operators previously &lt;code&gt;'and'&lt;/code&gt; and &lt;code&gt;'or'&lt;/code&gt;. A &lt;em&gt;logical operator&lt;/em&gt; allows us to perform logic between two things.&lt;br&gt;
Other logical operators include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Greater than &lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less than &lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Equal to &lt;code&gt;==&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Greater than or equal to &lt;code&gt;&amp;gt;=&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less than or equal to &lt;code&gt;&amp;lt;=&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Not equal to &lt;code&gt;!=&lt;/code&gt; &lt;em&gt;(Opposite of equal to)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;not&lt;/code&gt; keyword / Function - It negates the statement. Can also be written with bracket: &lt;code&gt;not()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They return either True or False:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(4 &amp;gt; 5)
False

&amp;gt;&amp;gt;&amp;gt; print(4 &amp;lt; 5)
True

&amp;gt;&amp;gt;&amp;gt; print(4 == 5)
False

&amp;gt;&amp;gt;&amp;gt; print(1 &amp;gt;= 0)
True

&amp;gt;&amp;gt;&amp;gt; print(1 &amp;lt;= 0)
False

&amp;gt;&amp;gt;&amp;gt; print(0 &amp;gt;= 0)
True

&amp;gt;&amp;gt;&amp;gt; print(0 != 0)
False

&amp;gt;&amp;gt;&amp;gt; print(not(True))
False

&amp;gt;&amp;gt;&amp;gt; print(not True)
False

&amp;gt;&amp;gt;&amp;gt; print(not False)
True

&amp;gt;&amp;gt;&amp;gt; print(not(1 == 1))
False

&amp;gt;&amp;gt;&amp;gt; print(not(1 != 1))
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; A single equal sign &lt;code&gt;=&lt;/code&gt; symbol is used in assigning values to variables hence to use the "equal to" operator for comparison, we use a double &lt;code&gt;==&lt;/code&gt; symbol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print('a' &amp;gt; 'b')
False

&amp;gt;&amp;gt;&amp;gt; print('a' &amp;gt; 'A')
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;But why/how is 'a' &amp;gt; 'b' False; and 'a' &amp;gt; 'A' True?&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the case of strings, Python compares the ASCII values of the characters. Hence, 'a' ASCII value is 97, 'b' is 98 and 'A' ASCII value is 65 that's why 'a' is greater than 'A' and 'b' is greater than 'a'.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;*optional&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
In the case of, &lt;code&gt;print('abc' &amp;lt; 'bac')&lt;/code&gt;, the result will be &lt;code&gt;True&lt;/code&gt;. &lt;em&gt;(Though this is a bit beyond the scope of the course)&lt;/em&gt;. &lt;br&gt;
This kind of comparison uses lexicographical ordering: first the first two items are compared, and if they differ this determines the outcome of the comparison; if they are equal, the next two items are compared, and so on, until either sequence is exhausted.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Lexicographical ordering for strings uses the Unicode code point number to order individual characters.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(1 &amp;lt; 2 &amp;lt; 3 &amp;lt; 4)
True

&amp;gt;&amp;gt;&amp;gt; print(1 &amp;lt; 2 &amp;gt; 3 &amp;lt; 4)
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Exercise1&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;(Done below)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You have been hired by a gaming company to create a program for a game where the character has magic powers and is an expert.&lt;br&gt;
If the character has magic and is an expert, the output should be "You are a master magician". Otherwise, if the character has magic but is not an expert, the output should be "At least you're getting there". Else, if the character has no magic, the output should be "You need magic powers".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print("Enter '1'(Yes) or '0'(No) for each question.")
&amp;gt;&amp;gt;&amp;gt; has_magic = bool(int(input("Does the character has magic? ")))
&amp;gt;&amp;gt;&amp;gt; is_expert = bool(int(input("Is the character an expert? ")))

&amp;gt;&amp;gt;&amp;gt; if has_magic and is_expert:
&amp;gt;&amp;gt;&amp;gt;   print("You are a master magician.")
&amp;gt;&amp;gt;&amp;gt; elif has_magic and not is_expert:
&amp;gt;&amp;gt;&amp;gt;   print("At least you're getting there.")
&amp;gt;&amp;gt;&amp;gt; elif not has_magic:
&amp;gt;&amp;gt;&amp;gt;  print("You need magic powers.")
Enter '1'(Yes) or '0'(No) for each question.
Does the character has magic? _1_
Is the character an expert? _1_
You are a master magician.

(Re-run the program)
Enter '1'(Yes) or '0'(No) for each question.
Does the character has magic? _0_
Is the character an expert? _1_
You need magic powers.

(Re-run the program)
Enter '1'(Yes) or '0'(No) for each question.
Does the character has magic? _1_
Is the character an expert? _0_
At least you're getting there.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;'is' keyword&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unlike the double equal sign &lt;code&gt;==&lt;/code&gt;, which compares the equality in values, &lt;code&gt;is&lt;/code&gt; is a keyword that checks if the location in memory where one value is stored is the same as the other's.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(True == 1)
&amp;gt;&amp;gt;&amp;gt; print('' == 1)
&amp;gt;&amp;gt;&amp;gt; print('1' == 1)
&amp;gt;&amp;gt;&amp;gt; print([] == 0)
&amp;gt;&amp;gt;&amp;gt; print(10 == 10.0)
&amp;gt;&amp;gt;&amp;gt; print([] == [])
&amp;gt;&amp;gt;&amp;gt; print([1, 2, 3] == [1, 2, 3])
True
False
False
False
True
True
True

&amp;gt;&amp;gt;&amp;gt; print(True is 1)
&amp;gt;&amp;gt;&amp;gt; print('' is 1)
&amp;gt;&amp;gt;&amp;gt; print('1' is 1)
&amp;gt;&amp;gt;&amp;gt; print([] is 0)
&amp;gt;&amp;gt;&amp;gt; print(10 is 10.0)
&amp;gt;&amp;gt;&amp;gt; print([] is [])
&amp;gt;&amp;gt;&amp;gt; print([1, 2, 3] is [1, 2, 3])
False
False
False
False
False
False
False

&amp;gt;&amp;gt;&amp;gt; print(True is True)
True

&amp;gt;&amp;gt;&amp;gt; print('1' is '1')
True

&amp;gt;&amp;gt;&amp;gt; print(10 is 10)
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once a list is created, it is stored in different memory space hence &lt;code&gt;print([] is [])&lt;/code&gt; or &lt;code&gt;print([1, 2, 3] is [1, 2, 3])&lt;/code&gt; will always evaluate to False.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;All &lt;em&gt;Data Structures&lt;/em&gt; in Python are stored in different memory locations.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;ul&gt;
&lt;li&gt;For Loops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Loops&lt;/strong&gt; are one of the most powerful features of a programming languages. The concept of looping allows us to run lines of code over and over till we accomplish a specific task.&lt;br&gt;
In creating a &lt;code&gt;for loop&lt;/code&gt;, we use the keyword &lt;code&gt;'for'&lt;/code&gt;.&lt;br&gt;
Example: &lt;code&gt;for i in 'name':&lt;/code&gt;&lt;br&gt;
'i' in the loop is a &lt;em&gt;variable&lt;/em&gt; for each element in the loop and can be any different name: &lt;code&gt;for item in 'name':&lt;/code&gt;, &lt;code&gt;for teddy in 'name':&lt;/code&gt; and is created for each item in 'name'(iterable).&lt;br&gt;
An &lt;em&gt;iterable&lt;/em&gt; is something that can be looped over.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for item in 'name':
&amp;gt;&amp;gt;&amp;gt;    print(item)
n
a
m
e

&amp;gt;&amp;gt;&amp;gt; for item in [1, 2, 3, 4]:
&amp;gt;&amp;gt;&amp;gt;    print(item)
1
2
3
4

&amp;gt;&amp;gt;&amp;gt; name = 'Mark'
&amp;gt;&amp;gt;&amp;gt; for i in name:
&amp;gt;&amp;gt;&amp;gt;    print(i)
M
a
r
k

&amp;gt;&amp;gt;&amp;gt; for item in {1, 2, 3, 4}:
&amp;gt;&amp;gt;&amp;gt;    print(item)
1
2
3
4

&amp;gt;&amp;gt;&amp;gt; for item in (1, 2, 3, 4):
&amp;gt;&amp;gt;&amp;gt;    print(item)
1
2
3
4

&amp;gt;&amp;gt;&amp;gt; for item in (1, 2, 3, 4):
&amp;gt;&amp;gt;&amp;gt;    print(item)
&amp;gt;&amp;gt;&amp;gt;    print(item)
&amp;gt;&amp;gt;&amp;gt;    print(item)
&amp;gt;&amp;gt;&amp;gt; print("Hello")

1
1
1
2
2
2
3
3
3
4
4
4
Hello

&amp;gt;&amp;gt;&amp;gt; for item in (1, 2, 3, 4):
&amp;gt;&amp;gt;&amp;gt;    print(item)
&amp;gt;&amp;gt;&amp;gt;    print(item)
&amp;gt;&amp;gt;&amp;gt;    print(item)
&amp;gt;&amp;gt;&amp;gt; print(item)
1
1
1
2
2
2
3
3
3
4
4
4
4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Nested for loops
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for item in (1, 2, 3, 4, 5):
&amp;gt;&amp;gt;&amp;gt;     for x in ['a', 'b', 'c']:
&amp;gt;&amp;gt;&amp;gt;         print(item, x)
1 a
1 b
1 c
2 a
2 b
2 c
3 a
3 b
3 c
4 a
4 b
4 c
5 a
5 b
5 c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Iterables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An iterable is an object or a collection that can be &lt;em&gt;iterated&lt;/em&gt; over (looped over).&lt;br&gt;
An iterable can be a list, tuple, dictionary, set and string. This means that one can go one by one checking each item in the collection.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Iterating over a dictionary&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
&amp;gt;&amp;gt;&amp;gt;     'name' : 'Mark',
&amp;gt;&amp;gt;&amp;gt;     'age' : 30,
&amp;gt;&amp;gt;&amp;gt;     'can_swim' : False
&amp;gt;&amp;gt;&amp;gt;   }

&amp;gt;&amp;gt;&amp;gt; for item in user:
&amp;gt;&amp;gt;&amp;gt;     print(item)
name
age
can_swim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;When we iterate over a dictionary we only get the keys but can use the dictionary methods to loop over the dictionary items which includes its values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One is &lt;code&gt;'x.items()'&lt;/code&gt; where we get the key-value pairs in tuples form.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
&amp;gt;&amp;gt;&amp;gt;     'name' : 'Mark',
&amp;gt;&amp;gt;&amp;gt;     'age' : 30,
&amp;gt;&amp;gt;&amp;gt;     'can_swim' : False
&amp;gt;&amp;gt;&amp;gt;   }

&amp;gt;&amp;gt;&amp;gt; for item in user.items():
&amp;gt;&amp;gt;&amp;gt;     print(item)
('name', 'Mark')
('age', 30)
('can_swim', False)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Second is &lt;code&gt;'x.values()'&lt;/code&gt; where we get only the values in the dictionary.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
&amp;gt;&amp;gt;&amp;gt;     'name' : 'Mark',
&amp;gt;&amp;gt;&amp;gt;     'age' : 30,
&amp;gt;&amp;gt;&amp;gt;     'can_swim' : False
&amp;gt;&amp;gt;&amp;gt;   }

&amp;gt;&amp;gt;&amp;gt; for item in user.values():
&amp;gt;&amp;gt;&amp;gt;     print(item)
Mark
30
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Third is &lt;code&gt;'x.keys()'&lt;/code&gt; where we get only the keys in the dictionary. Works the same as iterating the dictionary without including a method.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
&amp;gt;&amp;gt;&amp;gt;     'name' : 'Mark',
&amp;gt;&amp;gt;&amp;gt;     'age' : 30,
&amp;gt;&amp;gt;&amp;gt;     'can_swim' : False
&amp;gt;&amp;gt;&amp;gt;   }

&amp;gt;&amp;gt;&amp;gt; for item in user.keys():
&amp;gt;&amp;gt;&amp;gt;     print(item)
name
age
can_swim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;What if you want to print the items (key and values) in the dictionary separately? We can use &lt;code&gt;tuple unpacking&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
&amp;gt;&amp;gt;&amp;gt;     'name' : 'Mark',
&amp;gt;&amp;gt;&amp;gt;     'age' : 30,
&amp;gt;&amp;gt;&amp;gt;     'can_swim' : False
&amp;gt;&amp;gt;&amp;gt;   }

&amp;gt;&amp;gt;&amp;gt; for item in user.items():
&amp;gt;&amp;gt;&amp;gt;     key, value = item
&amp;gt;&amp;gt;&amp;gt;     print(key, value)
name Mark
age 30
can_swim False

(second way of unpacking)

&amp;gt;&amp;gt;&amp;gt; user = {
&amp;gt;&amp;gt;&amp;gt;     'name' : 'Mark',
&amp;gt;&amp;gt;&amp;gt;     'age' : 30,
&amp;gt;&amp;gt;&amp;gt;     'can_swim' : False
&amp;gt;&amp;gt;&amp;gt;   }

&amp;gt;&amp;gt;&amp;gt; for key, value in user.items():
&amp;gt;&amp;gt;&amp;gt;     print(key, value)
name Mark
age 30
can_swim False

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Exercise2&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;(Done below)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Building a simple 'counter' to loop over a list and sum up the items in the list. The list is provided below.&lt;br&gt;
&lt;code&gt;my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]&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;&amp;gt;&amp;gt;&amp;gt; my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
&amp;gt;&amp;gt;&amp;gt; sum = 0
&amp;gt;&amp;gt;&amp;gt; for i in my_list:
&amp;gt;&amp;gt;&amp;gt;     sum += i
&amp;gt;&amp;gt;&amp;gt; print (sum)
55
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;range() in loops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It returns an object that produces a sequence of integers from the start (which is inclusive) to stop (exclusive).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(range(100))
range(0, 100)

&amp;gt;&amp;gt;&amp;gt; print(range(0, 100))
range(0, 100)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can iterate a range of numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for num in range(20)
&amp;gt;&amp;gt;&amp;gt;    print(num)
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

&amp;gt;&amp;gt;&amp;gt; for i in range(2, 15)
&amp;gt;&amp;gt;&amp;gt;    print(i)
2
3
4
5
6
7
8
9
10
11
12
13
14

&amp;gt;&amp;gt;&amp;gt; for i in range(10):
&amp;gt;&amp;gt;&amp;gt;    print('my name is')
my name is
my name is
my name is
my name is
my name is
my name is
my name is
my name is
my name is
my name is
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When one &lt;em&gt;'does not want to use'&lt;/em&gt; a variable name in the loop, the person can use an underscore &lt;code&gt;_&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;&amp;gt;&amp;gt;&amp;gt; for _ in range(20)
&amp;gt;&amp;gt;&amp;gt;    print(_)
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

&amp;gt;&amp;gt;&amp;gt; for _ in range(10):
&amp;gt;&amp;gt;&amp;gt;    print('my name is')
my name is
my name is
my name is
my name is
my name is
my name is
my name is
my name is
my name is
my name is
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;(start: stop: stepover) in range()
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for _ in range(0, 10, 2)
&amp;gt;&amp;gt;&amp;gt;    print(_)
0
2
4
6
8

&amp;gt;&amp;gt;&amp;gt; for _ in range(0, 10, -1)
&amp;gt;&amp;gt;&amp;gt;    print(_)
#nothing will be printed out

&amp;gt;&amp;gt;&amp;gt; for _ in range(10, 0, -1)
&amp;gt;&amp;gt;&amp;gt;    print(_)
10
9
8
7
6
5
4
3
2
1

&amp;gt;&amp;gt;&amp;gt; for _ in range(10, 0, -2)
&amp;gt;&amp;gt;&amp;gt;    print(_)
10
8
6
4
2

&amp;gt;&amp;gt;&amp;gt; for _ in range(2)
&amp;gt;&amp;gt;&amp;gt;    print(list(range(10)))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;enumerate()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It returns each item in the iterable with its index in tuple form.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for i in enumerate('mark'):
&amp;gt;&amp;gt;&amp;gt;    print(i)
(0, 'm')
(1, 'a')
(2, 'r')
(3, 'k')

&amp;gt;&amp;gt;&amp;gt; for i, j in enumerate('mark'):
&amp;gt;&amp;gt;&amp;gt;    print(i, j)
0 m
1 a
2 r
3 k

&amp;gt;&amp;gt;&amp;gt; for i, char in enumerate(list(range(100))):
&amp;gt;&amp;gt;&amp;gt;     if char == 50:
&amp;gt;&amp;gt;&amp;gt;         print(f"The index of 50 is: {i}")
The index of 50 is: 50

&amp;gt;&amp;gt;&amp;gt; for i, j in enumerate('Mark'):
&amp;gt;&amp;gt;&amp;gt;     if j == 'r':
&amp;gt;&amp;gt;&amp;gt;         print(f"The index of r is: {i}")
The index of r is: 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;While Loops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In &lt;code&gt;While loop&lt;/code&gt;, a command is run when a specific condition is met till the condition becomes false after constant looping.&lt;br&gt;
eg:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while 0 &amp;lt; 50:
&amp;gt;&amp;gt;&amp;gt;     print(i)
0
0
0
0
0
#will run infinitely for 0 will always be less than 50.

&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; 50:
&amp;gt;&amp;gt;&amp;gt;     i += 5
&amp;gt;&amp;gt;&amp;gt;     print(i)
5
10
15
20
25
30
35
40
45
50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;break command in while loop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a &lt;code&gt;break&lt;/code&gt; keyword is used in &lt;code&gt;while loop&lt;/code&gt;, it breaks the loop after the first run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while 0 &amp;lt; 50:
&amp;gt;&amp;gt;&amp;gt;     print(i)
&amp;gt;&amp;gt;&amp;gt;     break
0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;using else in while loop
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; 50:
&amp;gt;&amp;gt;&amp;gt;     i += 5
&amp;gt;&amp;gt;&amp;gt;     print(i)
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;     print("Done with work")
5
10
15
20
25
30
35
40
45
50
Done with work

&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;gt; 50:
&amp;gt;&amp;gt;&amp;gt;     i += 5
&amp;gt;&amp;gt;&amp;gt;     print(i)
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;     print("Done with work")
Done with work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;else&lt;/code&gt; block in &lt;code&gt;while loop&lt;/code&gt; will only execute when there is no &lt;code&gt;break&lt;/code&gt; statement in the &lt;code&gt;while loop&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;&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; 50:
&amp;gt;&amp;gt;&amp;gt;     i += 5
&amp;gt;&amp;gt;&amp;gt;     print(i)
&amp;gt;&amp;gt;&amp;gt;     break
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;     print("Done with work")
0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;How &lt;code&gt;for loops&lt;/code&gt; and &lt;code&gt;while loops&lt;/code&gt; relates
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_list = [1, 2, 3]
&amp;gt;&amp;gt;&amp;gt; for item in my_list:
&amp;gt;&amp;gt;&amp;gt;     print(item)
1
2
3
------------------------------------
&amp;gt;&amp;gt;&amp;gt; my_list = [1, 2, 3]
&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; len(my_list):
&amp;gt;&amp;gt;&amp;gt;     print(my_list[i])
&amp;gt;&amp;gt;&amp;gt;     i += 1 
1
2
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;While loops&lt;/code&gt; are more flexible for we have a conditional statement but &lt;code&gt;for loops&lt;/code&gt; are simpler. With the &lt;code&gt;while loop&lt;/code&gt;, we have to remember to hope the loop in the course or use a break statement, to avoid getting an infinite loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; while True:
&amp;gt;&amp;gt;&amp;gt;     input("Say something: ")
&amp;gt;&amp;gt;&amp;gt;     break
Say something: _hi_

&amp;gt;&amp;gt;&amp;gt; while True:
&amp;gt;&amp;gt;&amp;gt;     response = input("Say something: ")
&amp;gt;&amp;gt;&amp;gt;     if (response == "bye"):
&amp;gt;&amp;gt;&amp;gt;         break
Say something: _hi_
Say something: _hi_
Say something: _bye_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;break, continue, pass&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;break&lt;/code&gt; keyword breaks out of the loop. The &lt;code&gt;continue&lt;/code&gt; keyword continues the loop till the condition is met without running the indented line(s) below it. The &lt;code&gt;pass&lt;/code&gt; keyword is used to pass to the next line. It is mainly used as a placeholder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_list = [1, 2, 3]
&amp;gt;&amp;gt;&amp;gt; for item in my_list:
&amp;gt;&amp;gt;&amp;gt;    continue
&amp;gt;&amp;gt;&amp;gt;    print(item)
#nothing will be printed

&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; len(my_list):
&amp;gt;&amp;gt;&amp;gt;    i += 1
&amp;gt;&amp;gt;&amp;gt;    continue
&amp;gt;&amp;gt;&amp;gt;    print(my_list[i])
#nothing will be printed

&amp;gt;&amp;gt;&amp;gt; my_list = [1, 2, 3]
&amp;gt;&amp;gt;&amp;gt; for item in my_list:
&amp;gt;&amp;gt;&amp;gt;    pass

&amp;gt;&amp;gt;&amp;gt; i = 0
&amp;gt;&amp;gt;&amp;gt; while i &amp;lt; len(my_list):
&amp;gt;&amp;gt;&amp;gt;    print(my_list[i])
&amp;gt;&amp;gt;&amp;gt;    i += 1
&amp;gt;&amp;gt;&amp;gt;    pass
1
2
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Exercise3&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;(Done below)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Our First GUI Exercise 🥳 (Basic Version)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this exercise, we are going to simulate what the computer does when we have a graphical user interface (GUI).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Assuming below are the pixels of an image (Christmas Tree in a nested list),&lt;/em&gt;;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;picture = [
   [0, 0, 0, 1, 0, 0, 0],
   [0, 0, 1, 1, 1, 0, 0],
   [0, 1, 1, 1, 1, 1, 0],
   [1, 1, 1, 1, 1, 1, 1],
   [0, 0, 0, 1, 0, 0, 0],
   [0, 0, 0, 1, 0, 0, 0]
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You gonna loop over the list(s) and the moment you encounter a zero(0), you will display on the screen 'an empty space' but when you encounter a one(1), you gonna simulate a pixel hence display a star(*).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For this challenge, we will include a new special print parameter(option) known as '&lt;code&gt;end =&lt;/code&gt;'&lt;/em&gt;. &lt;br&gt;
By default, the &lt;code&gt;print&lt;/code&gt; function ends with a newline (when we print anything, we get a new line for the next statement). Passing the whitespace to the end parameter &lt;code&gt;(end=' ')&lt;/code&gt; indicates that the end character has to be identified by whitespace and not a newline which we will use, for in this case, we don't want a new line after printing each and every character.&lt;br&gt;
&lt;code&gt;end =&lt;/code&gt; - "String appended after the last value".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(Without using the 'end' parameter)

&amp;gt;&amp;gt;&amp;gt; picture = [
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 1, 1, 1, 0, 0],
       [0, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1],
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0]
    ]

&amp;gt;&amp;gt;&amp;gt; for row in picture:
&amp;gt;&amp;gt;&amp;gt;    for pixel in row:
&amp;gt;&amp;gt;&amp;gt;       if pixel == 0:
&amp;gt;&amp;gt;&amp;gt;          print(" ")
&amp;gt;&amp;gt;&amp;gt;       else:
&amp;gt;&amp;gt;&amp;gt;          print("*")



*





*
*
*



*
*
*
*
*

*
*
*
*
*
*
*



*






*




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

&lt;/div&gt;



&lt;p&gt;(After using the end parameter to include a blank space 'empty string' after the end of the line)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; picture = [
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 1, 1, 1, 0, 0],
       [0, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1],
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0]
    ]

&amp;gt;&amp;gt;&amp;gt; for row in picture:
&amp;gt;&amp;gt;&amp;gt;    for pixel in row:
&amp;gt;&amp;gt;&amp;gt;       if pixel == 0:
&amp;gt;&amp;gt;&amp;gt;          print(" ", end = ' ')
&amp;gt;&amp;gt;&amp;gt;       else:
&amp;gt;&amp;gt;&amp;gt;          print("*", end = ' ')

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

&lt;/div&gt;



&lt;p&gt;(After each loop of the pixels, we also wanna include a blank space 'empty string' so that each single loop will be by default in each line):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; picture = [
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 1, 1, 1, 0, 0],
       [0, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1],
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0]
    ]

&amp;gt;&amp;gt;&amp;gt; for row in picture:
&amp;gt;&amp;gt;&amp;gt;    for pixel in row:
&amp;gt;&amp;gt;&amp;gt;       if pixel == 0:
&amp;gt;&amp;gt;&amp;gt;          print(" ", end = ' ')
&amp;gt;&amp;gt;&amp;gt;       else:
&amp;gt;&amp;gt;&amp;gt;          print("*", end = ' ')
&amp;gt;&amp;gt;&amp;gt;    print(" ")

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Exercise4&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;(Done below)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(Finding Duplicates in a list using loops and conditional logic)&lt;br&gt;
&lt;code&gt;Note:&lt;/code&gt; No use of sets in this case.&lt;br&gt;
After finding the duplicate values, the program should print the duplicate values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; some_list = ['a', 'b', 'c', 'b', 'd', 'm', 'n', 'n']
&amp;gt;&amp;gt;&amp;gt; duplicates = []
&amp;gt;&amp;gt;&amp;gt; for value in some_list:
&amp;gt;&amp;gt;&amp;gt;    if some_list.count(value) &amp;gt; 1:
&amp;gt;&amp;gt;&amp;gt;        if value not in duplicates:
&amp;gt;&amp;gt;&amp;gt;            duplicates.append(value)
&amp;gt;&amp;gt;&amp;gt; print(duplicates)
['b', 'n']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Up until now, we've worked with python functions like &lt;code&gt;print&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, &lt;code&gt;input&lt;/code&gt; function and many more that allowed us to perform actions on our data types.&lt;br&gt;
We can also create our own functions and use them on our program.&lt;br&gt;
When creating functions in Python we use the &lt;code&gt;def&lt;/code&gt; - 'define' keyword. We then give our function a name (defining the function) as we do with variables then we add the brackets () and a colon at the end.&lt;br&gt;
&lt;em&gt;For one to use a function one has to 'call it'.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def say_hello(): #defining the function
&amp;gt;&amp;gt;&amp;gt;    print("Hellooo")
&amp;gt;&amp;gt;&amp;gt; say_hello() #calling the function
Hellooo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Functions are super useful because the work under the principle of 'DRY - Don't Repeat Yourself' because instead of the programmer re-typing the code each and every time, the programmer can just call the function as many times as possible to run a specific block of code.&lt;/p&gt;

&lt;p&gt;Example: Using our Christmas tree example above, we can use the function to output it multiple of times.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; picture = [
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 1, 1, 1, 0, 0],
       [0, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1],
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0]
    ]

&amp;gt;&amp;gt;&amp;gt; def show_tree():
&amp;gt;&amp;gt;&amp;gt;    for row in picture:
&amp;gt;&amp;gt;&amp;gt;        for pixel in row:
&amp;gt;&amp;gt;&amp;gt;            if pixel == 0:
&amp;gt;&amp;gt;&amp;gt;                print(" ", end = ' ')
&amp;gt;&amp;gt;&amp;gt;            else:
&amp;gt;&amp;gt;&amp;gt;                print("*", end = ' ')
&amp;gt;&amp;gt;&amp;gt;        print(" ")

&amp;gt;&amp;gt;&amp;gt; show_tree()
&amp;gt;&amp;gt;&amp;gt; show_tree()
&amp;gt;&amp;gt;&amp;gt; show_tree()

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The function is stored in a specific place in memory once created.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def say_hello(): 
&amp;gt;&amp;gt;&amp;gt;    print("Hellooo")
&amp;gt;&amp;gt;&amp;gt; print(say_hello)
&amp;lt;function say_hello at 0x000002332BB33E20&amp;gt;

#The characters '0x000002332BB33E20' show the memory location where the function has been stored.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Arguments Vs Parameters(in functions)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The power of functions beyond it being able to be called multiple times, is the ability of the programmer to make it dynamic. In its brackets, one can pass parameters.&lt;br&gt;
The values which are defined at the time of the &lt;em&gt;function prototype&lt;/em&gt; or &lt;em&gt;definition of the function&lt;/em&gt; are called as &lt;strong&gt;&lt;u&gt;parameters&lt;/u&gt;&lt;/strong&gt;.&lt;br&gt;
When a function is 'called', the actual values that are passed during the 'call' are called as &lt;strong&gt;&lt;u&gt;arguments&lt;/u&gt;&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def say_hello(name, age): #name and age are parameters.
&amp;gt;&amp;gt;&amp;gt;    print(f"Hello {name}, You're {age} yrs")
&amp;gt;&amp;gt;&amp;gt; say_hello("Mark", 20) #"Mark" and 20 are arguments.
Hello Mark, You're 20 yrs

&amp;gt;&amp;gt;&amp;gt; def say_hello(name, age):
&amp;gt;&amp;gt;&amp;gt;    print(f"Hello {name}, You're {age} yrs")
&amp;gt;&amp;gt;&amp;gt; say_hello("Mark", 20)
&amp;gt;&amp;gt;&amp;gt; say_hello("Emily", 19)
&amp;gt;&amp;gt;&amp;gt; say_hello("Dan", 17)
Hello Mark, You're 20 yrs
Hello Emily, You're 19 yrs
Hello Dan, You're 17 yrs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above arguments are referred to as &lt;strong&gt;&lt;u&gt;positional arguments&lt;/u&gt;&lt;/strong&gt; because they are required to be in the proper position.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def say_hello(name, age):
&amp;gt;&amp;gt;&amp;gt;    print(f"Hello {name}, You're {age} yrs")
&amp;gt;&amp;gt;&amp;gt; say_hello(20, "Mark")
Hello 20, You're Mark yrs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Default Parameters and Keyword Arguments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Keyword arguments&lt;/code&gt;, as opposed to &lt;code&gt;positional arguments&lt;/code&gt;, allow us to not worry about the position hence the arguments can be in any position.&lt;br&gt;
&lt;em&gt;However this makes the code more complicated and not a proper practice way.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def say_hello(name, age):
&amp;gt;&amp;gt;&amp;gt;    print(f"Hello {name}, You're {age} yrs")
&amp;gt;&amp;gt;&amp;gt; say_hello(age = 20, name = "Mark")
Hello Mark, You're 20 yrs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Default parameters&lt;/code&gt; allow us to give constant values as we define the function. Default parameters &lt;strong&gt;only&lt;/strong&gt; work when no values have been passed as arguments to the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def say_hello(name = "Emily", age = 17):
&amp;gt;&amp;gt;&amp;gt;    print(f"Hello {name}, You're {age} yrs")
&amp;gt;&amp;gt;&amp;gt; say_hello()
Hello Emily, You're 17 yrs

&amp;gt;&amp;gt;&amp;gt; def say_hello(name = "Emily", age = 17):
&amp;gt;&amp;gt;&amp;gt;    print(f"Hello {name}, You're {age} yrs")
&amp;gt;&amp;gt;&amp;gt; say_hello("Dan", 23)
&amp;gt;&amp;gt;&amp;gt; say_hello()
Hello Dan, You're 23 yrs
Hello Emily, You're 17 yrs

&amp;gt;&amp;gt;&amp;gt; def say_hello(name = "Emily", age = 17):
&amp;gt;&amp;gt;&amp;gt;    print(f"Hello {name}, You're {age} yrs")
&amp;gt;&amp;gt;&amp;gt; say_hello("Irene")
Hello Irene, You're 17 yrs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Return Statement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a keyword in python mostly used together with functions.&lt;br&gt;
Functions always have to return something and when there is no &lt;code&gt;return statement&lt;/code&gt;, the function will always return &lt;code&gt;None&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;&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    num1 + num2
&amp;gt;&amp;gt;&amp;gt; print(sum(4, 5))
None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the return statement is used;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    return num1 + num2
&amp;gt;&amp;gt;&amp;gt; print(sum(4, 5))
9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;A function should do one thing really well and/or should return something. This however doesn't mean that the code only has to be one line.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    return num1 + num2
&amp;gt;&amp;gt;&amp;gt; total = sum(10, 5)
&amp;gt;&amp;gt;&amp;gt; print(sum(10, total))
25

&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    return num1 + num2
&amp;gt;&amp;gt;&amp;gt; print(sum(10, sum(10, 5)))
25

&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    def another_func(num1, num2):
&amp;gt;&amp;gt;&amp;gt;       return num1 + num2
&amp;gt;&amp;gt;&amp;gt; total = sum(10, 20)
&amp;gt;&amp;gt;&amp;gt; print(total)
None

def sum(num1, num2):
   def another_func(num1, num2):
      return num1 + num2
   return another_func
total = sum(10, 20)
print(total)
&amp;lt;function sum.&amp;lt;locals&amp;gt;.another_func at 0x000002387BF49B40&amp;gt;

&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    def another_func(num1, num2):
&amp;gt;&amp;gt;&amp;gt;       return num1 + num2
&amp;gt;&amp;gt;&amp;gt;    return another_func
&amp;gt;&amp;gt;&amp;gt; total = sum(10, 20)
&amp;gt;&amp;gt;&amp;gt; print(total(10, 20))
30

&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    def another_func(num1, num2):
&amp;gt;&amp;gt;&amp;gt;       return num1 + num2
&amp;gt;&amp;gt;&amp;gt;    return another_func(num1, num2)
&amp;gt;&amp;gt;&amp;gt; total = sum(10, 20)
&amp;gt;&amp;gt;&amp;gt; print(total)
30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To avoid confusion when working with more than one function (function in a function), it is advisable to use different names for the parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    def another_func(n1, n2):
&amp;gt;&amp;gt;&amp;gt;       return num1 + num2
&amp;gt;&amp;gt;&amp;gt;    return another_func(num1, num2)
&amp;gt;&amp;gt;&amp;gt; total = sum(10, 20)
&amp;gt;&amp;gt;&amp;gt; print(total)
30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; A &lt;code&gt;return&lt;/code&gt; keyword automatically exits the function in that any code (to output) below the return statement is never run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def sum(num1, num2):
&amp;gt;&amp;gt;&amp;gt;    def another_func(n1, n2):
&amp;gt;&amp;gt;&amp;gt;       return num1 + num2
&amp;gt;&amp;gt;&amp;gt;    return another_func(num1, num2)
&amp;gt;&amp;gt;&amp;gt;    return 5
&amp;gt;&amp;gt;&amp;gt;    print("Hello")
&amp;gt;&amp;gt;&amp;gt; total = sum(10, 20)
&amp;gt;&amp;gt;&amp;gt; print(total)
30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Methods Vs Functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples of inbuilt functions in python include : &lt;code&gt;list()&lt;/code&gt;, &lt;code&gt;print()&lt;/code&gt;, &lt;code&gt;max()&lt;/code&gt;, &lt;code&gt;min()&lt;/code&gt;, &lt;code&gt;input()&lt;/code&gt;. We've also found out that we can use the keyword &lt;code&gt;def&lt;/code&gt; to define our own functions.&lt;/p&gt;

&lt;p&gt;When using methods, we use the dot(.) notation. Methods are owned by 'whatever is to the left of the dot(.)' be it strings, tuples, integers etc. Methods of the fundamental data types have been covered in the &lt;a href="https://dev.to/gateremark/python-from-the-word-go-4h93"&gt;previous module&lt;/a&gt; where all the data types have been covered too.&lt;br&gt;
Both Functions and Methods allow us to take actions on the data types.&lt;br&gt;
&lt;code&gt;None:&lt;/code&gt; Similar to functions, we can also build our own methods which will be explained in details in the next module as we discuss on 'classes and objects'.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docstrings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is using triple quotes ('''...''') to 'comment' multiple lines. It can also be used in functions to give more info about a function.&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%2Fiidvnocgqjgmzsb78q12.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%2Fiidvnocgqjgmzsb78q12.png" alt="Image description" width="683" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It works the same as the more info about a function provided by the developer environments when typing the inbuilt functions.&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%2Fe6meal4tovxblriz8ao9.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%2Fe6meal4tovxblriz8ao9.png" alt="Image description" width="681" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Help function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Used to give more info about a function. When a docstring is passed in a function, the help function returns the docstring.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; help(print)

print(...)
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.

-----------------------------------------------------------------

&amp;gt;&amp;gt;&amp;gt; def test(a):
       '''
       Info: This is a function that prints the testing data.
       '''
       print(a)
&amp;gt;&amp;gt;&amp;gt; help(test)
test(a)
    Info: This is a function that prints the testing data.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also use the dunder method (Magic method) &lt;em&gt;'will get into it later in the course'&lt;/em&gt; to get more info on a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def test(a):
       '''
       Info: This is a function that prints the testing data.
       '''
       print(a)
&amp;gt;&amp;gt;&amp;gt;print(test.__doc___)
Info: This is a function that prints the testing data.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Docstrings are really useful to add comments and definition to a function to enable other people understand what your function does without searching through your multiple files.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Writing clean code
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def is_even(num):
&amp;gt;&amp;gt;&amp;gt;    if num % 2 == 0:
&amp;gt;&amp;gt;&amp;gt;      return True
&amp;gt;&amp;gt;&amp;gt;    elif num % 2 != 0:
&amp;gt;&amp;gt;&amp;gt;      return False
&amp;gt;&amp;gt;&amp;gt; print(is_even(50))
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def is_even(num):
&amp;gt;&amp;gt;&amp;gt;    if num % 2 == 0:
&amp;gt;&amp;gt;&amp;gt;      return True
&amp;gt;&amp;gt;&amp;gt;    else:
&amp;gt;&amp;gt;&amp;gt;      return False
&amp;gt;&amp;gt;&amp;gt; print(is_even(50))
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def is_even(num):
&amp;gt;&amp;gt;&amp;gt;    if num % 2 == 0:
&amp;gt;&amp;gt;&amp;gt;      return True
&amp;gt;&amp;gt;&amp;gt;    return False
&amp;gt;&amp;gt;&amp;gt; print(is_even(50))
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def is_even(num):
&amp;gt;&amp;gt;&amp;gt;    return num % 2 == 0
&amp;gt;&amp;gt;&amp;gt; print(is_even(50))
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;*args and **kwargs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*args - arguments&lt;br&gt;
**kwargs - Keyword arguments&lt;/p&gt;

&lt;p&gt;In function we have special characters called &lt;code&gt;*args&lt;/code&gt; and &lt;code&gt;**kwargs&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;&amp;gt;&amp;gt;&amp;gt; def super_func(num):
&amp;gt;&amp;gt;&amp;gt;    return sum(num)
&amp;gt;&amp;gt;&amp;gt; super_func(1, 2, 3, 4, 5)
#returns an error because the function should take just 1 positional argument but we gave 5.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;_args (adding an asterisk at the start of the parameter) allows one to pass more than one positional argument.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def super_func(*num):
&amp;gt;&amp;gt;&amp;gt;    print(*num)
&amp;gt;&amp;gt;&amp;gt;    return sum(num)
&amp;gt;&amp;gt;&amp;gt; super_func(1, 2, 3, 4, 5)
1 2 3 4 5

&amp;gt;&amp;gt;&amp;gt; def super_func(*num):
&amp;gt;&amp;gt;&amp;gt;    print(num)
&amp;gt;&amp;gt;&amp;gt;    return sum(num)
&amp;gt;&amp;gt;&amp;gt; super_func(1, 2, 3, 4, 5)
(1 2 3 4 5)

&amp;gt;&amp;gt;&amp;gt; def super_func(*num):
&amp;gt;&amp;gt;&amp;gt;    return sum(num)
&amp;gt;&amp;gt;&amp;gt; print(super_func(1, 2, 3, 4, 5))
15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;__kwargs allows us to use keyword arguments.&lt;/strong&gt; It returns a dictionary of the values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def super_func(*num, **kwargs):
&amp;gt;&amp;gt;&amp;gt;    print(kwargs)
&amp;gt;&amp;gt;&amp;gt; super_func(1, 2, 3, 4, 5, num1=10, num2=15)
{'num1': 10, 'num2': 15}

&amp;gt;&amp;gt;&amp;gt; def super_func(*num, **kwargs):
&amp;gt;&amp;gt;&amp;gt;    print(kwargs)
&amp;gt;&amp;gt;&amp;gt;    total = 0
&amp;gt;&amp;gt;&amp;gt;     for items in kwargs.values():
&amp;gt;&amp;gt;&amp;gt;        total += items
&amp;gt;&amp;gt;&amp;gt;     return sum(num) + total
&amp;gt;&amp;gt;&amp;gt; print(super_func(1, 2, 3, 4, 5, num1=10, num2=15))
{'num1': 10, 'num2': 15}
40
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's a rule of positioning when one is using parameters, default parameters, *args and **kwargs:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;parameters, *args, default parameters, **kwargs&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def super_func(name, *num, greet="hi", **kwargs):
&amp;gt;&amp;gt;&amp;gt;    print(kwargs)
&amp;gt;&amp;gt;&amp;gt;    total = 0
&amp;gt;&amp;gt;&amp;gt;     for items in kwargs.values():
&amp;gt;&amp;gt;&amp;gt;        total += items
&amp;gt;&amp;gt;&amp;gt;     return sum(num) + total
&amp;gt;&amp;gt;&amp;gt; print(super_func("Andy", 1, 2, 3, 4, 5, num1=10, num2=15))
{'num1': 10, 'num2': 15}
40
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Exercise5&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;(Done below)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create a function called 'highest_even' that is passed a list of integers and returns the highest even integer.&lt;br&gt;
The list is given below:&lt;br&gt;
&lt;code&gt;my_list = [10, 2, 3, 8, 4, 11]&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;&amp;gt;&amp;gt;&amp;gt; my_list = [10, 2, 3, 4, 8, 11]
&amp;gt;&amp;gt;&amp;gt; even_list = []
&amp;gt;&amp;gt;&amp;gt; def highest_even():
&amp;gt;&amp;gt;&amp;gt;    for i in my_list:
&amp;gt;&amp;gt;&amp;gt;       if i % 2 == 0:
&amp;gt;&amp;gt;&amp;gt;          even_list.append(i)
&amp;gt;&amp;gt;&amp;gt;          even_list.sort()
&amp;gt;&amp;gt;&amp;gt;          print(even_list)
&amp;gt;&amp;gt;&amp;gt;    print(even_list[-1])
&amp;gt;&amp;gt;&amp;gt; highest_even()
[10]
[2, 10]
[2, 4, 10]
[2, 4, 8, 10]
10

-------------------------------------------------------------

&amp;gt;&amp;gt;&amp;gt; my_list = [10, 2, 3, 4, 8, 11]
&amp;gt;&amp;gt;&amp;gt; even_list = []
&amp;gt;&amp;gt;&amp;gt; def highest_even():
&amp;gt;&amp;gt;&amp;gt;    for i in my_list:
&amp;gt;&amp;gt;&amp;gt;       if i % 2 == 0:
&amp;gt;&amp;gt;&amp;gt;          even_list.append(i)
&amp;gt;&amp;gt;&amp;gt;          even_list.sort()
&amp;gt;&amp;gt;&amp;gt;    print(even_list[-1])
&amp;gt;&amp;gt;&amp;gt; highest_even()
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also use the &lt;code&gt;max&lt;/code&gt; keyword to return the maximum even number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_list = [10, 2, 3, 4, 8, 11]
&amp;gt;&amp;gt;&amp;gt; def highest_even():
&amp;gt;&amp;gt;&amp;gt;    even_list = []
&amp;gt;&amp;gt;&amp;gt;    for i in my_list:
&amp;gt;&amp;gt;&amp;gt;       if i % 2 == 0:
&amp;gt;&amp;gt;&amp;gt;          even_list.append(i)
&amp;gt;&amp;gt;&amp;gt;    return max(even_list)
&amp;gt;&amp;gt;&amp;gt; print(highest_even())
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Walrus Operator (:=)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;walrus operator&lt;/code&gt; is a new feature in &lt;code&gt;python 3.8&lt;/code&gt;.&lt;br&gt;
It is explained in depths in &lt;a href="https://docs.python.org/3/whatsnew/3.8.html"&gt;the python documentation&lt;/a&gt;. &lt;br&gt;
It is used to assign values to variables as part of a 'larger expression' eg. in &lt;code&gt;if statements&lt;/code&gt;, in &lt;code&gt;while loops&lt;/code&gt; etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = "Helloooooooooooooooo"
&amp;gt;&amp;gt;&amp;gt; if (len(a) &amp;gt; 10):
&amp;gt;&amp;gt;&amp;gt;     print(f"Too long, {len(a)} elements")
Too long, 20 elements
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the walrus operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = "Helloooooooooooooooo"
&amp;gt;&amp;gt;&amp;gt; if ((n := len(a)) &amp;gt; 10):
&amp;gt;&amp;gt;&amp;gt;     print(f"Too long, {n} elements")
Too long, 20 elements
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Walrus Operator (while loop)&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = "Helloooooooooooooooo"
&amp;gt;&amp;gt;&amp;gt; while ((n := len(a)) &amp;gt; 1):
&amp;gt;&amp;gt;&amp;gt;     print(n)
&amp;gt;&amp;gt;&amp;gt;     a = a[:-1]
&amp;gt;&amp;gt;&amp;gt; print(a)
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
H

-----------------------------------------------------------------

&amp;gt;&amp;gt;&amp;gt; a = "Helloooooooooooooooo"
&amp;gt;&amp;gt;&amp;gt; while ((n := len(a)) &amp;gt; 1):
&amp;gt;&amp;gt;&amp;gt;     print(a)
&amp;gt;&amp;gt;&amp;gt;     a = a[:-1]
&amp;gt;&amp;gt;&amp;gt; print(a)
Helloooooooooooooooo
Hellooooooooooooooo
Helloooooooooooooo
Hellooooooooooooo
Helloooooooooooo
Hellooooooooooo
Helloooooooooo
Hellooooooooo
Helloooooooo
Hellooooooo
Helloooooo
Hellooooo
Helloooo
Hellooo
Helloo
Hello
Hell
Hel
He
H
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;Scope &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;"What variables do I have access to?"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(name)
#returns an error; NameError: name 'name' is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once a variable is not defined, one cannot have access to it.&lt;br&gt;
A variable with a &lt;strong&gt;global scope&lt;/strong&gt; is a variable that can be accessed by anybody in the file and can be used anywhere; in the conditional logic; in the while loop; in a function, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; total = 100
&amp;gt;&amp;gt;&amp;gt; print(total)
100

#total has a global scope
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A variable with a &lt;strong&gt;functional scope&lt;/strong&gt; is a variable that can only be accessed in within the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def some_func():
&amp;gt;&amp;gt;&amp;gt;    total = 100
&amp;gt;&amp;gt;&amp;gt; print(total)
#returns an error; NameError: name 'total' is not defined

&amp;gt;&amp;gt;&amp;gt; def some_func():
&amp;gt;&amp;gt;&amp;gt;    total = 100
&amp;gt;&amp;gt;&amp;gt;    print(total)
100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Scope Rules&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;"What would you expect the output of the code below to be?"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = 1
&amp;gt;&amp;gt;&amp;gt; def confusion():
&amp;gt;&amp;gt;&amp;gt;   a = 5
&amp;gt;&amp;gt;&amp;gt;   return a
&amp;gt;&amp;gt;&amp;gt; print(a)
&amp;gt;&amp;gt;&amp;gt; print(confusion())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;5&lt;/code&gt;. This is because the first print function, &lt;code&gt;print(a)&lt;/code&gt;, outputs the value stored in the &lt;code&gt;a&lt;/code&gt; with the global scope while the second print function, &lt;code&gt;print(confusion())&lt;/code&gt;, returns the value stored in the &lt;code&gt;a&lt;/code&gt; variable in the function.&lt;br&gt;
The &lt;code&gt;a&lt;/code&gt; is not modified after the function because of &lt;code&gt;scope&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Rules the interpreter follow in scope:&lt;/p&gt;
&lt;h5&gt;
  
  
  1. Local Scope - Scope within the functional scope.
&lt;/h5&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = 1
&amp;gt;&amp;gt;&amp;gt; def confusion():
&amp;gt;&amp;gt;&amp;gt;   a = 5
&amp;gt;&amp;gt;&amp;gt;   return a
&amp;gt;&amp;gt;&amp;gt; print(confusion())
&amp;gt;&amp;gt;&amp;gt; print(a)
5
1

&amp;gt;&amp;gt;&amp;gt; a = 1
&amp;gt;&amp;gt;&amp;gt; def confusion():
&amp;gt;&amp;gt;&amp;gt;   return a
&amp;gt;&amp;gt;&amp;gt; print(confusion())
&amp;gt;&amp;gt;&amp;gt; print(a)
1
1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h5&gt;
  
  
  2. Parent Local scope - Works where there's a function within a function.
&lt;/h5&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = 1
&amp;gt;&amp;gt;&amp;gt; def parent():
&amp;gt;&amp;gt;&amp;gt;   a = 10
&amp;gt;&amp;gt;&amp;gt;   def confusion():
&amp;gt;&amp;gt;&amp;gt;      return a
&amp;gt;&amp;gt;&amp;gt;   return confusion()
&amp;gt;&amp;gt;&amp;gt; print(parent())
&amp;gt;&amp;gt;&amp;gt; print(a)
10
1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h5&gt;
  
  
  3. Global scope
&lt;/h5&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = 1
&amp;gt;&amp;gt;&amp;gt; def parent():
&amp;gt;&amp;gt;&amp;gt;   def confusion():
&amp;gt;&amp;gt;&amp;gt;      return a
&amp;gt;&amp;gt;&amp;gt;   return confusion()
&amp;gt;&amp;gt;&amp;gt; print(parent())
&amp;gt;&amp;gt;&amp;gt; print(a)
1
1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h5&gt;
  
  
  4. Built in python functions
&lt;/h5&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a = 1
&amp;gt;&amp;gt;&amp;gt; def parent():
&amp;gt;&amp;gt;&amp;gt;   def confusion():
&amp;gt;&amp;gt;&amp;gt;      return sum
&amp;gt;&amp;gt;&amp;gt;   return confusion()
&amp;gt;&amp;gt;&amp;gt; print(parent())
&amp;gt;&amp;gt;&amp;gt; print(a)
&amp;lt;built-in function sum&amp;gt;
1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; Parameters are part of the local scope:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; b = 10
&amp;gt;&amp;gt;&amp;gt; def confusion(b):
&amp;gt;&amp;gt;&amp;gt;    print(b)
&amp;gt;&amp;gt;&amp;gt; confusion(300)
300

&amp;gt;&amp;gt;&amp;gt; b = 10
&amp;gt;&amp;gt;&amp;gt; def confusion(b):
&amp;gt;&amp;gt;&amp;gt;    print(b)
&amp;gt;&amp;gt;&amp;gt; confusion(b)
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Global keyword&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;"What if one wants to refer to a global variable while in the function without creating a new variable?"&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; total = 0
&amp;gt;&amp;gt;&amp;gt; def count():
&amp;gt;&amp;gt;&amp;gt;    total += 1
&amp;gt;&amp;gt;&amp;gt;    return total
&amp;gt;&amp;gt;&amp;gt; print(count())
#returns an error; UnboundLocalError: local variable 'total' referenced before assignment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The error occurs because the function &lt;code&gt;count&lt;/code&gt; does not recognize &lt;code&gt;total&lt;/code&gt;. Hence, we have to add a variable &lt;code&gt;total&lt;/code&gt; in the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; total = 0
&amp;gt;&amp;gt;&amp;gt; def count():
&amp;gt;&amp;gt;&amp;gt;    total = 0
&amp;gt;&amp;gt;&amp;gt;    total += 1
&amp;gt;&amp;gt;&amp;gt;    return total
&amp;gt;&amp;gt;&amp;gt; print(count())
1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To avoid recreating another variable in the function we can use the &lt;code&gt;global keyword&lt;/code&gt; to tell the interpreter that we want to use the global scope on the variable in the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; total = 0
&amp;gt;&amp;gt;&amp;gt; def count():
&amp;gt;&amp;gt;&amp;gt;    global total
&amp;gt;&amp;gt;&amp;gt;    total += 1
&amp;gt;&amp;gt;&amp;gt;    return total
&amp;gt;&amp;gt;&amp;gt; print(count())
1

&amp;gt;&amp;gt;&amp;gt; total = 0
&amp;gt;&amp;gt;&amp;gt; def count():
&amp;gt;&amp;gt;&amp;gt;    global total
&amp;gt;&amp;gt;&amp;gt;    total += 1
&amp;gt;&amp;gt;&amp;gt;    return total
&amp;gt;&amp;gt;&amp;gt; count()
&amp;gt;&amp;gt;&amp;gt; count()
&amp;gt;&amp;gt;&amp;gt; print(count())
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Dependency injection (A simplified version of global scope)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; total = 0
&amp;gt;&amp;gt;&amp;gt; def count(total):
&amp;gt;&amp;gt;&amp;gt;    total += 1
&amp;gt;&amp;gt;&amp;gt;    return total
&amp;gt;&amp;gt;&amp;gt; print(count(total))
1

&amp;gt;&amp;gt;&amp;gt; total = 0
&amp;gt;&amp;gt;&amp;gt; def count(total):
&amp;gt;&amp;gt;&amp;gt;    total += 1
&amp;gt;&amp;gt;&amp;gt;    return total
&amp;gt;&amp;gt;&amp;gt; print(count(count(count(total))))
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Nonlocal Keyword&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a new keyword(feature) in python 3 and its used to refer to the parent local scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def outer():
&amp;gt;&amp;gt;&amp;gt;    x = "local"
&amp;gt;&amp;gt;&amp;gt;    def inner():
&amp;gt;&amp;gt;&amp;gt;       nonlocal x
&amp;gt;&amp;gt;&amp;gt;       x = "nonlocal"
&amp;gt;&amp;gt;&amp;gt;       print("inner:", x)
&amp;gt;&amp;gt;&amp;gt;    inner()
&amp;gt;&amp;gt;&amp;gt;    print("outer:", x)
&amp;gt;&amp;gt;&amp;gt; outer()
inner: nonlocal
outer: nonlocal

#Without the nonlocal keyword

&amp;gt;&amp;gt;&amp;gt; def outer():
&amp;gt;&amp;gt;&amp;gt;    x = "local"
&amp;gt;&amp;gt;&amp;gt;    def inner():
&amp;gt;&amp;gt;&amp;gt;       x = "nonlocal"
&amp;gt;&amp;gt;&amp;gt;       print("inner:", x)
&amp;gt;&amp;gt;&amp;gt;    inner()
&amp;gt;&amp;gt;&amp;gt;    print("outer:", x)
&amp;gt;&amp;gt;&amp;gt; outer()
inner: nonlocal
outer: local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Why do we need scope?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"Why not just have every variable with a global scope so that everything has access to everything?"&lt;br&gt;
Machines don't have infinite power/memory hence we need to be cautious of the resources we use. Scope is a good demonstration of this.&lt;br&gt;
Eg. When a function is run, we create one memory space hence when for instance we use nonlocal, we instead of creating another memory space, we use an existing one.&lt;/p&gt;



&lt;p&gt;Hurraay!! 🥳&lt;br&gt;
We come to the end of the second module. Hope you've learnt a lot and ready to implement the skills in different fields. &lt;br&gt;
As we wrap up, here is a simple exercise for you to try before checking the answer done below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; age = input("What is your age?: ")
&amp;gt;&amp;gt;&amp;gt; if int(age) &amp;lt; 18:
&amp;gt;&amp;gt;&amp;gt;     print("Sorry, you are too young to drive this car. Powering off!")
&amp;gt;&amp;gt;&amp;gt; elif int(age) &amp;gt; 18:
&amp;gt;&amp;gt;&amp;gt;     print("Powering On. Enjoy the ride!");
&amp;gt;&amp;gt;&amp;gt; else:
&amp;gt;&amp;gt;&amp;gt;     print("Congratulations on your first year of driving. Enjoy the ride!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Given the code above, perform the actions below on the code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Wrap the above code in a function called checkDriverAge() that whenever you call this function, you will get prompted for age.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instead of using the input(), make the checkDriverAge() function accept an argument of age, so that if you enter eg. checkDriverAge(92), it returns "Powering On. Enjoy the ride!"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make the default age set to 0 if no argument is given.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; def checkDriverAge(age=0):
&amp;gt;&amp;gt;&amp;gt;    if int(age) &amp;lt; 18:
&amp;gt;&amp;gt;&amp;gt;        print("Sorry, you are too young to drive this car. Powering off")
&amp;gt;&amp;gt;&amp;gt;    elif int(age) &amp;gt; 18:
&amp;gt;&amp;gt;&amp;gt;        print("Powering On. Enjoy the ride!");
&amp;gt;&amp;gt;&amp;gt;    else:
&amp;gt;&amp;gt;&amp;gt;        print("Congratulations on your first year of driving. Enjoy the ride!")
&amp;gt;&amp;gt;&amp;gt; checkDriverAge(10)
Sorry, you are too young to drive this car. Powering off
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;What next? 🤔&lt;br&gt;
Let's meet in the next module &lt;code&gt;#Advanced Python1&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Till next time; bye bye.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>career</category>
    </item>
    <item>
      <title>Python from the word ...Go</title>
      <dc:creator>Mark Gatere</dc:creator>
      <pubDate>Tue, 24 May 2022 14:40:43 +0000</pubDate>
      <link>https://dev.to/gateremark/python-from-the-word-go-4h93</link>
      <guid>https://dev.to/gateremark/python-from-the-word-go-4h93</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Basics Part1&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;What is programming?&lt;/code&gt;&lt;br&gt;
In simple terms, programming is a way for us to give instructions to computers. "Giving it an &lt;em&gt;instruction manual&lt;/em&gt;, and the computer follows".&lt;/p&gt;

&lt;p&gt;Computers don't understand English or any other human language for that matter. Computers speak in 1s and 0s; &lt;em&gt;On or Off&lt;/em&gt; (So is all the other electronic component).&lt;br&gt;
But for humans, it would be gibberish or rather difficult to communicate in 1s or 0s. Humans have then developed programming languages that work in between human language and machine language (0s / 1s).&lt;br&gt;
Some programming languages are low-level (closer to machine language) while others are high-level (closer to human language).&lt;br&gt;
Examples of low-level programming languages include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assembly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples of high-level programming languages include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python &lt;/li&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What then is a &lt;code&gt;programming language&lt;/code&gt;?&lt;br&gt;
A programming language is any set of rules that convert strings, or graphical program elements, to various kinds of machine code output (that is understandable to the computer).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; At the end of the day, all programming languages do the same thing, &lt;em&gt;they tell the machine what to do&lt;/em&gt;. However, different languages have different modes of doing it.&lt;br&gt;
The beauty is that "most languages have very similar principles."&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The hardest part is only in learning the first language.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In between the programming language and the machine language, we need a 'translator' that understands both the programming language (source code) and machine language and hence can translate our code to machine language for the computers to understand.&lt;br&gt;
&lt;code&gt;*The translator ain't a person&lt;/code&gt; but rather another program that can either be an interpreter or a compiler.&lt;br&gt;
Like a &lt;em&gt;translator&lt;/em&gt;, an interpreter goes line by line throughout the code and executes the code on the machine. In contrast, a compiler takes the code and reads the entire file all at once and translates it to machine code. (&lt;em&gt;Their other major differences are a little complicated and beyond the scope of the course&lt;/em&gt;)&lt;br&gt;
&lt;strong&gt;Python usually uses an interpreter&lt;/strong&gt; hence to use python you have to download the interpreter.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; To learn or understand more on any of the topics below, here is a link to the official &lt;a href="https://docs.python.org/3/tutorial/index.html"&gt;Python Documentation.&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Python interpreter
&lt;/h2&gt;

&lt;p&gt;To download the python interpreter, we first visit &lt;a href="https://www.python.org/"&gt;python.org&lt;/a&gt;.&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%2Fr8q93ltm8o3yly7ezv16.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%2Fr8q93ltm8o3yly7ezv16.PNG" alt="Python Official Site" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under Downloads; Click on either Windows or Mac OS depending on one's operating system. (&lt;em&gt;The system will automatically detect the specifications of your computer and either suggest 32bit or 64bit for they using Windows OS&lt;/em&gt;)&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%2Fw2c95wjax8696uci7wrc.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%2Fw2c95wjax8696uci7wrc.PNG" alt="Python Interpreter" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After downloading is complete, click to load the setup.&lt;br&gt;
&lt;strong&gt;Note:&lt;/strong&gt; While installing, don't forget to mark 'checked' for the option "Add Python to PATH" as shown below:&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%2Ftofdweqhqxvpl184z4y2.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%2Ftofdweqhqxvpl184z4y2.PNG" alt="Add Python to PATH" width="666" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking 'Install Now', the installation will commence immediately:&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%2Fed6x8t45t9l1ew7zb3tx.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%2Fed6x8t45t9l1ew7zb3tx.PNG" alt="Installation in Progress" width="666" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...and after a successful installation, the program will notify you:&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%2Fkhv6r55p26i6bg2cghjk.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%2Fkhv6r55p26i6bg2cghjk.PNG" alt="Successful Installation" width="666" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After installing python, you can use the terminal, (or on Windows) use Command Prompt or PowerShell to confirm whether Python has successfully been added to PATH.&lt;br&gt;
"Open either Command Prompt or PowerShell and type 'python' then click 'Enter' to run the command".&lt;br&gt;
For a successful installation and adding to PATH, both Command Prompt(Image1) and PowerShell(Image2), after running 'python', should look like the image below:&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%2F46674216ym8sfoqja332.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%2F46674216ym8sfoqja332.PNG" alt="Successfully added to PATH" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...but by chance there probably was a problem in installation or adding to PATH, after running the 'python' command, it will return an error but one can re-install the interpreter and remember to check 'Add Python to PATH'.&lt;/p&gt;


&lt;h2&gt;
  
  
  First "Hello World" Program
&lt;/h2&gt;

&lt;p&gt;After setting up the interpreter, we can use the terminal (Command Prompt, GIT Bash, PowerShell, Termux ...etc) to run a few of python commands.&lt;br&gt;
Open the terminal and first run 'python' command. Secondly, use the python command "print" to display characters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print("I am using python")
I am using python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Setting up the environment (IDE Setup)
&lt;/h2&gt;

&lt;p&gt;We have previously just run our first python program but in a profession, one cannot run the entire company's program on the terminal. It is mainly used for quick testing.&lt;br&gt;
In most cases, we use code editors or IDEs to run python programs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why not write code in a word document or a text file?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In a word document, the code will be in form of text hence in case of a syntax error, no information will be returned. In addition, professional developers need some extra tools that code editors and IDEs provide that help them to be more efficient with their code.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;What is a code editor and an IDE, and what is their difference?&lt;/code&gt;&lt;br&gt;
Code editors are lightweight and give some features like auto-completion, while IDEs are full-fledged environments and provide a tone of extra features like debugging, auto-completion, code formatting, code snippets ...etc.&lt;br&gt;
The most popular code editors and IDEs for Python include: Sublime Text, Visual Studio Code, PyCharm and Jupyter Notebooks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To install, setup, customize and use Sublime Text: &lt;a href="https://drive.google.com/file/d/1SjQNaNU1WzLl7MV_1XZNkkH2-TdXyP3F/view?usp=sharing"&gt;Link&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To install, setup, customize and use Visual Studio Code: &lt;a href="https://drive.google.com/file/d/1K3alOYWFujDQQXoa2qZGg3xveCVErptM/view?usp=sharing"&gt;Link&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To install, setup, customize and use PyCharm: &lt;a href="https://drive.google.com/file/d/1LBjXb1NoQYp0mrgZmtOLL__zB6Ixnywc/view?usp=sharing"&gt;Link&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To install, setup, customize and use Jupyter Notebooks: &lt;a href="https://drive.google.com/file/d/1f_gcqYW51v6nItLxOBKsSEji-vbl_BGw/view?usp=sharing"&gt;Link&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Python Basics
&lt;/h2&gt;

&lt;p&gt;In order for any programmer to learn a language, there are 4 key things that they really need to master:&lt;/p&gt;

&lt;p&gt;i). Terms of the language - Different words and definitions are used in the language eg. Variables, statements, and instantiation.&lt;br&gt;
ii). Language Data Types - Integers, strings ...etc.&lt;br&gt;
iii). Actions - Using memory and performing some actions.&lt;br&gt;
iv). Best practices of writing a language.&lt;/p&gt;
&lt;h5&gt;
  
  
  1. Variables
&lt;/h5&gt;

&lt;p&gt;Variables are memory locations that store information that can be used in a program.&lt;br&gt;
They act like &lt;em&gt;'containers'&lt;/em&gt; that store/hold an item(s).&lt;br&gt;
They can hold user(s) input, values ..etc.&lt;br&gt;
eg.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; name = "Mark"
&amp;gt;&amp;gt;&amp;gt; print(name)
Mark

Hence, 'name' is a variable that stores the name, Mark.

&amp;gt;&amp;gt;&amp;gt; iq = 190
&amp;gt;&amp;gt;&amp;gt; print(iq)
190
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; Assigning a value to a variable is known as binding.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;u&gt;Rules of declaring variables&lt;/u&gt;
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;snake_case
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user_iq = 190
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;start with lowercase or underscore
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; _useriq = 190
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;letters, numbers, underscores
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; us4er_iq = 190
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Case sensitive
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user_iq = 190
&amp;gt;&amp;gt;&amp;gt; user_IQ = 200

&amp;gt;&amp;gt;&amp;gt; print(user_iq)
190

&amp;gt;&amp;gt;&amp;gt; print(user_IQ)
200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Don't overwrite python keywords -
&lt;code&gt;One cannot assign values to python keywords.&lt;/code&gt;
To find the list of complete keywords in python, click the following &lt;a href="https://www.w3schools.com/python/python_ref_keywords.asp"&gt;link.&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Variables can also be re-assigned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; iq = 190
&amp;gt;&amp;gt;&amp;gt; user_age = iq/4
&amp;gt;&amp;gt;&amp;gt; print(user_age)
47.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Constants&lt;/code&gt; - These are variables that are not meant to change.&lt;br&gt;
They are written in uppercase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; PI = 3.14 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Dunder Variables&lt;/code&gt; - Preceded by a double underscore. (Will look at them later in the course)&lt;br&gt;
Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;__debug__
__loader__
__import__
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assigning values to variables multiple times:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a, b, c = 1, 2, 3
&amp;gt;&amp;gt;&amp;gt; print(a)
1
&amp;gt;&amp;gt;&amp;gt; print(b)
2
&amp;gt;&amp;gt;&amp;gt; print(c)
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; &lt;strong&gt;Variables should be descriptive.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Expressions Vs Statements&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; iq = 100
&amp;gt;&amp;gt;&amp;gt; user_age = iq / 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Expression is a piece of code that produces a value.
eg: &lt;code&gt;iq / 5&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Statement is the entire line of code that performs some sort of action.&lt;br&gt;
eg: &lt;code&gt;iq = 100&lt;/code&gt;, &lt;code&gt;user_age = iq / 5&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Augmented Assignment Operator&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; some_value = 5
&amp;gt;&amp;gt;&amp;gt; some_value = some_value + 2
&amp;gt;&amp;gt;&amp;gt; print(some_value)
7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Can also be written as)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; some_value = 5
&amp;gt;&amp;gt;&amp;gt; some_value += 2
&amp;gt;&amp;gt;&amp;gt; print(some_value)
7

&amp;gt;&amp;gt;&amp;gt; some_value = 5
&amp;gt;&amp;gt;&amp;gt; some_value -= 2
&amp;gt;&amp;gt;&amp;gt; print(some_value)
3

&amp;gt;&amp;gt;&amp;gt; some_value = 5
&amp;gt;&amp;gt;&amp;gt; some_value *= 2
&amp;gt;&amp;gt;&amp;gt; print(some_value)
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  2. Python Data Types
&lt;/h5&gt;

&lt;p&gt;A data type is a classification of data which tells the compiler or interpreter how the programmer intends to use the data. It is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error.&lt;br&gt;
In Python, data types include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fundamental Data Types
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-Text Type:
str - string

-Numeric Types:
int - integer
float
complex

-Sequence Types:
list
tuple
range

-Mapping Type:
dict - dictionary

-Set Types:
set
frozenset

-Boolean Type:
bool - boolean

-Binary Types:
bytes
bytearray
memoryview

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Custom Data Types - Created from classes&lt;/li&gt;
&lt;li&gt;Specialized Data Types - Extensions from Modules&lt;/li&gt;
&lt;li&gt;None Type - &lt;code&gt;None&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;a.) int - Integer&lt;br&gt;
An integer is a whole number with no decimal point; 1, 2, 3, 4, 456, -4643, -77.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(2 + 4)
6

&amp;gt;&amp;gt;&amp;gt; print(2 - 4)
-2

&amp;gt;&amp;gt;&amp;gt; print(2 * 4)
8

&amp;gt;&amp;gt;&amp;gt; print(type(2))
&amp;lt;class 'int'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; print(type(-29))
&amp;lt;class 'int'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; print(type(2 + 4))
&amp;lt;class 'int'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; print(type(2 - 4))
&amp;lt;class 'int'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;b.) float&lt;br&gt;
These are numbers with a decimal point; 5.7, 8.0, 3.5554, 0.00003, -0.543, -4.229.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(2 / 4)
0.5

&amp;gt;&amp;gt;&amp;gt; print(type(2.7))
&amp;lt;class 'float'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; print(type(-27.554))
&amp;lt;class 'float'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; print(type(2.8 + 4))
&amp;lt;class 'float'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; print(type(2 / 4))
&amp;lt;class 'float'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; - floats take up a lot of space in memory than integers.&lt;br&gt;
This is because the number(s) need to be stored in memory in binary form. But when there's a decimal place eg. 10.56, it is difficult to represent that in a binary form(0s / 1s) because of the point &lt;code&gt;'.'&lt;/code&gt; hence a floating-point number is stored in two different locations eg. one for 10 and the other for 56.&lt;/p&gt;

&lt;p&gt;To learn more about floating-point numbers, here is a link to the python documentation on &lt;a href="https://docs.python.org/3/tutorial/floatingpoint.html"&gt;floating-point numbers.&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operations on integers and floats.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;operators&lt;/code&gt; + , - , * , / , ** , // , %&lt;/p&gt;

&lt;p&gt;&lt;code&gt;+ ----- addition&lt;/code&gt;&lt;br&gt;
&lt;code&gt;- ----- subtraction&lt;/code&gt;&lt;br&gt;
&lt;code&gt;* ----- multiplication&lt;/code&gt;&lt;br&gt;
&lt;code&gt;/ ----- division&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;** ---- 'power of'&lt;br&gt;
eg.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(2 ** 4)
16

&amp;gt;&amp;gt;&amp;gt; print(7 ** 9)
40,353,607
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;// ---- 'rounds down the quotient to the nearest whole number'&lt;br&gt;
eg.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(2 // 4)
0

&amp;gt;&amp;gt;&amp;gt; print(3 // 4)
0

&amp;gt;&amp;gt;&amp;gt; print(4 // 4)
1

&amp;gt;&amp;gt;&amp;gt; print(5 // 4)
1

&amp;gt;&amp;gt;&amp;gt; print(7 // 4)
1

&amp;gt;&amp;gt;&amp;gt; print(9 // 4)
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;% ---- 'returns the remainder'&lt;br&gt;
eg.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(5 % 4)
1

&amp;gt;&amp;gt;&amp;gt; print(5 % 2)
1

&amp;gt;&amp;gt;&amp;gt; print(5 % 3)
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Math Functions (Actions performed on integers and floats).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;i) round - rounds off the number to the nearest whole number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(round(3.1))
3

&amp;gt;&amp;gt;&amp;gt; print(round(3.9))
4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ii) abs - returns the absolute value of the argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(abs(-20))
20

&amp;gt;&amp;gt;&amp;gt; print(abs(-354))
354

&amp;gt;&amp;gt;&amp;gt; print(abs(44))
44
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;iii) pow - used to calculate a number to its specific power.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(pow(2,3))
8

&amp;gt;&amp;gt;&amp;gt; print(pow(4,3))
64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;iv) max - returns the highest number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(max(2,3))
3

&amp;gt;&amp;gt;&amp;gt; print(max(2,-9))
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;v) min - returns the least number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(min(3,8))
3

&amp;gt;&amp;gt;&amp;gt; print(min(2,-9))
-9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For most of the other mathematical functions to be used, they have to be 'imported' from the math module.&lt;br&gt;
&lt;code&gt;from math import *&lt;/code&gt;&lt;br&gt;
The * symbol means 'everything' hence we import all the functions from the math module.&lt;/p&gt;

&lt;p&gt;i) floor - rounds down the number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; from math import *

&amp;gt;&amp;gt;&amp;gt; print(floor(3.7))
3

&amp;gt;&amp;gt;&amp;gt; print(floor(5.9))
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ii) ceil - rounds up the number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; from math import *

&amp;gt;&amp;gt;&amp;gt; print(ceil(3.2))
4

&amp;gt;&amp;gt;&amp;gt; print(ceil(5.9))
5

&amp;gt;&amp;gt;&amp;gt; print(ceil(5.3))
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;iii) sqrt - returns the square root of a number&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; from math import *

&amp;gt;&amp;gt;&amp;gt; print(sqrt(4))
2.0

&amp;gt;&amp;gt;&amp;gt; print(sqrt(9))
3.0

&amp;gt;&amp;gt;&amp;gt; print(sqrt(121))
11.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;To get more mathematical functions used in python,&lt;/code&gt; &lt;a href="https://docs.python.org/3/library/math.html"&gt;click the following link.&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operator Precedence (BODMAS)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;B - brackets&lt;br&gt;
O - power off&lt;br&gt;
D - division&lt;br&gt;
M - multiplication&lt;br&gt;
A - addition&lt;br&gt;
S - subtraction&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(20 - 3 * 4)
8

&amp;gt;&amp;gt;&amp;gt; print((20 - 3) * 4)
68

&amp;gt;&amp;gt;&amp;gt; print((20 - 3) + 2 ** 2)
21
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Conversion to binary *&lt;code&gt;optional&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(bin(5))
0b101

&amp;gt;&amp;gt;&amp;gt; print(int('0b101', 2))
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;c.) str - String&lt;br&gt;
A string is a piece of text. It can either be written with double or single quotation marks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; greetings = "hi, hello there!"
&amp;gt;&amp;gt;&amp;gt; print(greetings)
hi, hello there!

&amp;gt;&amp;gt;&amp;gt; greetings = 'Welcome!'
&amp;gt;&amp;gt;&amp;gt; print(greetings)
Welcome!

&amp;gt;&amp;gt;&amp;gt; print(type("hi, hello there!"))
&amp;lt;class 'str'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For long strings/sentences (strings that include a lot of lines) we use triple quotes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; passage = ''' Mark Gatere is a student.
    He is currently at University pursuing his degree program.
    He wants to become a Data Scientist in future.'''
&amp;gt;&amp;gt;&amp;gt; print(passage)
Mark Gatere is a student.
He is currently at University pursuing his degree program.
He wants to become a Data Scientist in future.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Working with strings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;String Concatenation&lt;/strong&gt;&lt;br&gt;
Concatenation is the action of linking things together in a series hence, string concatenation is joining multiple strings to one in series.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; first_name = "Mark"
&amp;gt;&amp;gt;&amp;gt; second_name = "Gatere"
&amp;gt;&amp;gt;&amp;gt; full_name = first_name + second_name
&amp;gt;&amp;gt;&amp;gt; print(full_name)
MarkGatere

&amp;gt;&amp;gt;&amp;gt; first_name = "Mark"
&amp;gt;&amp;gt;&amp;gt; second_name = "Gatere"
&amp;gt;&amp;gt;&amp;gt; full_name = first_name + ' ' + second_name
&amp;gt;&amp;gt;&amp;gt; print(full_name)
Mark Gatere
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Type Conversion&lt;/strong&gt;&lt;br&gt;
This is converting a value from one data type to another.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print(type(str(100)))
&amp;lt;class 'str'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; a = str(100)
&amp;gt;&amp;gt;&amp;gt; b = int(a)
&amp;gt;&amp;gt;&amp;gt; a_type = type(a)
&amp;gt;&amp;gt;&amp;gt; b_type = type(b)
&amp;gt;&amp;gt;&amp;gt; print(a_type)
&amp;lt;class 'str'&amp;gt;
&amp;gt;&amp;gt;&amp;gt; print(b_type)
&amp;lt;class 'int'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Escape Sequences&lt;/strong&gt;&lt;br&gt;
We use a backslash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; weather = 'It\'s sunny'
&amp;gt;&amp;gt;&amp;gt; print(weather)
It's sunny

&amp;gt;&amp;gt;&amp;gt; weather = "It's \"kind of\" sunny"
&amp;gt;&amp;gt;&amp;gt; print(weather)
It's "kind of" sunny

&amp;gt;&amp;gt;&amp;gt; weather = 'It\\s sunny'
&amp;gt;&amp;gt;&amp;gt; print(weather)
It\s sunny
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;\t is used to add a tab to the output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; weather = '\t It\'s sunny'
&amp;gt;&amp;gt;&amp;gt; print(weather)
    It's sunny
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;\n is used to take the part after it to a new line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; weather = "It's sunny \n hope you have a good day."
&amp;gt;&amp;gt;&amp;gt; print(weather)
It's sunny
hope you have a good day
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Formatted Strings&lt;/strong&gt; (f-string)&lt;br&gt;
An 'f' is added at the start of the expected output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; name = "Johnny"
&amp;gt;&amp;gt;&amp;gt; age = 55
&amp;gt;&amp;gt;&amp;gt; print ("hi" + name + ". You are" + str(age) + "years old.")
hi Johnny. You are 55 years old.

(can also be written as)

&amp;gt;&amp;gt;&amp;gt; name = "Johnny"
&amp;gt;&amp;gt;&amp;gt; age = 55
&amp;gt;&amp;gt;&amp;gt; print (f"hi {name}. You are {age} years old.")
hi Johnny. You are 55 years old.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In python 2 (but also works in python 3):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; name = "Johnny"
&amp;gt;&amp;gt;&amp;gt; age = 55
&amp;gt;&amp;gt;&amp;gt; print ("hi {}. You are {} years old.".format(name, age))
hi Johnny. You are 55 years old.

&amp;gt;&amp;gt;&amp;gt; name = "Johnny"
&amp;gt;&amp;gt;&amp;gt; age = 55
&amp;gt;&amp;gt;&amp;gt; print ("hi {1}. You are {0} years old.".format(name, age))
hi 55. You are Johnny years old.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String Indexes&lt;/strong&gt;&lt;br&gt;
A string is stored in a memory as ordered pieces of characters.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;my name is&lt;/code&gt;&lt;br&gt;
&lt;code&gt;0123456789&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To access each character in a string, we use an index. Indexing starts from zero(0).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; sentence = "my name is Mark"
&amp;gt;&amp;gt;&amp;gt; print(sentence[3])
n

&amp;gt;&amp;gt;&amp;gt; sentence = "my name is Mark"
&amp;gt;&amp;gt;&amp;gt; print(sentence[8])
i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String Slicing&lt;/strong&gt;&lt;br&gt;
[start:stop] - We start from the stated index but stop at but not including the index given.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[0:7])
0123456

&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[0:8])
01234567

&amp;gt;&amp;gt;&amp;gt; sentence = "my name is Mark"
&amp;gt;&amp;gt;&amp;gt; print(sentence[1:10])
y name is

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

&lt;/div&gt;



&lt;p&gt;[start:stop:stepover]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[0:8:2])
0246

&amp;gt;&amp;gt;&amp;gt; sentence = "my name is Mark"
&amp;gt;&amp;gt;&amp;gt; print(sentence[1:15:2])
ynm sMr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Extra ways to access the values using the indexes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[1:])
1234567

&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[:5])
01234

&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[::2])
0246

&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[-1])
7

&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[-2])
6

&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[-3])
5

&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[::-1])
76543210

&amp;gt;&amp;gt;&amp;gt; number = '01234567'
&amp;gt;&amp;gt;&amp;gt; print(number[::-2])
7531
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Immutability&lt;/strong&gt;&lt;br&gt;
Strings in Python are immutable (they cannot be changed).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Built-in string Functions and methods&lt;/strong&gt;&lt;br&gt;
len() - used to find the number of characters in a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; greet = "Hello"
&amp;gt;&amp;gt;&amp;gt; print(len(greet))
5

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

&lt;/div&gt;



&lt;p&gt;x.upper() - capitalizes or changes the entire string to uppercase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; greet = "Hello"
&amp;gt;&amp;gt;&amp;gt; print(greet.upper)
HELLO
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.lower() - changes the entire string to lowercase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; greet = "HELLO"
&amp;gt;&amp;gt;&amp;gt; print(greet.lower)
hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.capitalize() - capitalizes the first character at the beginning of the string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; greet = "hello"
&amp;gt;&amp;gt;&amp;gt; print(greet.capitalize)
Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.isupper() - returns either True or False on whether the string is in uppercase.&lt;/p&gt;

&lt;p&gt;x.islower() - returns either True or False on whether the string is in lowercase.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using functions in combination with each other.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; phrase = "My name is Mark"
&amp;gt;&amp;gt;&amp;gt; print(phrase.upper().isupper())
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.find() - returns the index of the character(s) you're looking for in the string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; quote = "to be or not to be"
&amp;gt;&amp;gt;&amp;gt; print(quote.find("be"))
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.replace() - used to replace character(s) in a string with new character(s).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; quote = "to be or not to be"
&amp;gt;&amp;gt;&amp;gt; print(quote.replace("be", "me"))
to me or not to me

&amp;gt;&amp;gt;&amp;gt; quote = "to be or not to be"
&amp;gt;&amp;gt;&amp;gt; print(quote.replace("t", "y"))
yo be or noy yo be
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.index - returns the index of a specific character or the index where the characters start.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; greet = "hello"
&amp;gt;&amp;gt;&amp;gt; print(greet.index("e"))
1

&amp;gt;&amp;gt;&amp;gt; greet = "hello"
&amp;gt;&amp;gt;&amp;gt; print(greet.index("l"))
2

&amp;gt;&amp;gt;&amp;gt; greet = "hello"
&amp;gt;&amp;gt;&amp;gt; print(greet.index("lo"))
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;To learn more on string methods,&lt;/code&gt; click the following &lt;a href="https://www.w3schools.com/python/python_ref_string.asp"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d.) bool - booleans&lt;br&gt;
This data type consists of either True or False.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; is_cool = True
&amp;gt;&amp;gt;&amp;gt; print(is_cool)
True

&amp;gt;&amp;gt;&amp;gt; is_tall = False
&amp;gt;&amp;gt;&amp;gt; print(is_tall)
False

&amp;gt;&amp;gt;&amp;gt; print(bool(1))
True

&amp;gt;&amp;gt;&amp;gt; print(bool(0))
False

&amp;gt;&amp;gt;&amp;gt; print(bool('True'))
True

&amp;gt;&amp;gt;&amp;gt; print(bool('False'))
True

&amp;gt;&amp;gt;&amp;gt; print(bool())
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; A Boolean value is always True as far as there's a value. 0 or empty data will always return False as shown in the examples above.&lt;/p&gt;




&lt;p&gt;An important concept to learn before getting to learn more data types is - &lt;strong&gt;Getting input from Users.&lt;/strong&gt;&lt;br&gt;
You've encountered a form that requires to be filled out.&lt;br&gt;
The form is usually blank and requires specific details for each section including Name, Email address, and contact. An example is shown below:&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%2F0pyz1wz30p92d5pxeia4.jpg" 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%2F0pyz1wz30p92d5pxeia4.jpg" alt="Form" width="500" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Python, we also create programs that require input from the users hence allowing users of the program to input information into the program. To create these programs, we use the keyword &lt;code&gt;input&lt;/code&gt; which tells the interpreter that we require input from the user to continue with the other command.&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%2Flphcfvsfuezkyhk6ji0n.gif" 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%2Flphcfvsfuezkyhk6ji0n.gif" alt="Input" width="600" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; Every input from the user is stored by default as a string (including numbers) hence for any mathematical calculation, the input has to be converted to numerical, either integer or float.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; birth_year = input("What year were you born? ")
&amp;gt;&amp;gt;&amp;gt; age = 2022 - birth_year
&amp;gt;&amp;gt;&amp;gt; print(f"Your age is: {age} years old")
What year were you born? _2001_
#Will return an error as birth_year(string) cannot 
 be subtracted from 2022(integer).

&amp;gt;&amp;gt;&amp;gt; birth_year = input("What year were you born? ")
&amp;gt;&amp;gt;&amp;gt; age = 2022 - int(birth_year)
&amp;gt;&amp;gt;&amp;gt; print(f"Your age is: {age} years old")
What year were you born? _2001_
Your age is: 21 years old
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;em&gt;Exercise 1&lt;/em&gt; (Done Below)
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a simple calculator that asks for two numbers from the user, finds their sum and outputs the sum.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(Note the two different programs)

&amp;gt;&amp;gt;&amp;gt; num1 = input("Enter a number: ")
&amp;gt;&amp;gt;&amp;gt; num2 = input("Enter a second number: ")
&amp;gt;&amp;gt;&amp;gt; sum = num1 + num2
&amp;gt;&amp;gt;&amp;gt; print(sum)
Enter a number: _12_
Enter a second number: _5.2_
125.2

# Correct Program
&amp;gt;&amp;gt;&amp;gt; num1 = input("Enter a number: ")
&amp;gt;&amp;gt;&amp;gt; num2 = input("Enter a second number: ")
&amp;gt;&amp;gt;&amp;gt; sum = int(num1) + int(num2)
&amp;gt;&amp;gt;&amp;gt; print(sum)
Enter a number: _12_
Enter a second number: _5.2_
17.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;em&gt;Exercise 2&lt;/em&gt; (Done Below)
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a simple password checker that outputs the password in hidden format and outputs the number of characters in the password.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user_name = input("Enter your username: ")
&amp;gt;&amp;gt;&amp;gt; password = input("Enter your Password: ")
&amp;gt;&amp;gt;&amp;gt; pass_length = len(password)
&amp;gt;&amp;gt;&amp;gt; pass_hidden = 'x' * pass_length
&amp;gt;&amp;gt;&amp;gt; print(f"Hello {user_name}, your password: {pass_hidden} is {pass_length} characters long.")
Enter your username: _gateremark_
Enter your Password: _swddbb243tbfbd_
Hello gateremark, your password: xxxxxxxxxxxxxx is 14 characters long.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fe8e5b5uqxzgr3v8ibbdh.gif" 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%2Fe8e5b5uqxzgr3v8ibbdh.gif" alt="Exercise2" width="600" height="337"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Let's kick-off off our next data type:&lt;/p&gt;

&lt;p&gt;e.) Lists&lt;br&gt;
A list is an ordered sequence of objects of any type. It is denoted by square brackets [].&lt;br&gt;
It can have a collection of items of different data types and can at times be referred to as an array though there's a slight difference between a list and an array. (Will cover this later in the course).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; li = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; li2 = ['a', 'b', 'c', 'f']
&amp;gt;&amp;gt;&amp;gt; li3 = [1, 2, 'r', 'u', True]
&amp;gt;&amp;gt;&amp;gt; print(li)
&amp;gt;&amp;gt;&amp;gt; print(li2)
&amp;gt;&amp;gt;&amp;gt; print(li3)
[1, 2, 3, 4, 5]
['a', 'b', 'c', 'f']
[1, 2, 'r', 'u', True]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists are &lt;strong&gt;Data Structures.&lt;/strong&gt;&lt;br&gt;
A &lt;em&gt;Data Structure&lt;/em&gt; is a data organization, management, and storage format that enables efficient access and modification.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accessing individual items in a list (using index)
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; li3 = [1, 2, 'r', 'u', True]
&amp;gt;&amp;gt;&amp;gt; print(li3[2])
&amp;gt;&amp;gt;&amp;gt; print(li3[4])
r
True

&amp;gt;&amp;gt;&amp;gt; amazon_cart = ["notebooks", "sunglasses", "earphones"]
&amp;gt;&amp;gt;&amp;gt; print(amazon_cart[2])
earphones

&amp;gt;&amp;gt;&amp;gt; amazon_cart = ["notebooks", "sunglasses", "earphones"]
&amp;gt;&amp;gt;&amp;gt; print(amazon_cart[3])
#Returns an error for the index is out range.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;List Slicing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As we did in strings, we can use the index [start:stop] to access a specific range of items in a list.&lt;br&gt;
&lt;code&gt;Remember&lt;/code&gt; eg. [1:7] selects all items from index 1 to but not including the item in index 7 hence the last item is the item in index 6.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; amazon_cart = ["notebooks", 
                   "sunglasses", 
                   "earphones",
                   "toys",
                   "grapes"]
&amp;gt;&amp;gt;&amp;gt; print(amazon_cart[0:4])
['notebooks', 'sunglasses', 'earphones', 'toys']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;[start:stop:stepover]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; amazon_cart = ["notebooks", 
                   "sunglasses", 
                   "earphones",
                   "toys",
                   "grapes"]
&amp;gt;&amp;gt;&amp;gt; print(amazon_cart[::2])
['notebooks', 'earphones', 'grapes']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Modifying elements in a list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Lists&lt;/strong&gt;, unlike strings, &lt;strong&gt;are mutable&lt;/strong&gt; hence one can modify elements in a list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; amazon_cart = ["notebooks", 
                   "sunglasses", 
                   "earphones",
                   "toys",
                   "grapes"]
&amp;gt;&amp;gt;&amp;gt; amazon_cart[0] = "Laptop"
&amp;gt;&amp;gt;&amp;gt; print(amazon_cart)
['Laptop', 'sunglasses', 'earphones', 'toys', 'grapes']

&amp;gt;&amp;gt;&amp;gt; amazon_cart = ["notebooks", 
                   "sunglasses", 
                   "earphones",
                   "toys",
                   "grapes"]
&amp;gt;&amp;gt;&amp;gt; amazon_cart[0] = "Laptop"
&amp;gt;&amp;gt;&amp;gt; new_cart = amazon_cart[0:3]
&amp;gt;&amp;gt;&amp;gt; new_cart[1] = "gum"
&amp;gt;&amp;gt;&amp;gt; print(new_cart)
&amp;gt;&amp;gt;&amp;gt; print(amazon_cart)
['Laptop', 'gum', 'earphones']
['Laptop', 'sunglasses', 'earphones', 'toys', 'grapes']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; When you assign a list to a different variable, it points to the memory location of the original list hence modification of the list in the new variable leads to modification of the original list in the previous variable.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; amazon_cart = ["notebooks", 
                   "sunglasses", 
                   "earphones",
                   "toys",
                   "grapes"]
&amp;gt;&amp;gt;&amp;gt; amazon_cart[0] = "Laptop"
&amp;gt;&amp;gt;&amp;gt; new_cart = amazon_cart
&amp;gt;&amp;gt;&amp;gt; new_cart[0] = "gum"
&amp;gt;&amp;gt;&amp;gt; print(new_cart)
&amp;gt;&amp;gt;&amp;gt; print(amazon_cart)
['gum', 'sunglasses', 'earphones', 'toys', 'grapes']
['gum', 'sunglasses', 'earphones', 'toys', 'grapes']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To avoid modification of the original list after one has modified the list assigned in the new variable, we use [:] after the list variable to copy the entire list and store it as a new list in a different variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; amazon_cart = ["notebooks", 
                   "sunglasses", 
                   "earphones",
                   "toys",
                   "grapes"]
&amp;gt;&amp;gt;&amp;gt; amazon_cart[0] = "Laptop"
&amp;gt;&amp;gt;&amp;gt; new_cart = amazon_cart[:]
&amp;gt;&amp;gt;&amp;gt; new_cart[0] = "gum"
&amp;gt;&amp;gt;&amp;gt; print(new_cart)
&amp;gt;&amp;gt;&amp;gt; print(amazon_cart)
['gum', 'sunglasses', 'earphones', 'toys', 'grapes']
['Laptop', 'sunglasses', 'earphones', 'toys', 'grapes']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Matrix (These are multi-dimensional lists/arrays)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; matrix = [
      [2, 4, 6],
      [9, 5, 7],
      [3, 8, 1]
    ]
&amp;gt;&amp;gt;&amp;gt; print(matrix)
[[2, 4, 6], [9, 5, 7], [3, 8, 1]]

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

&lt;/div&gt;



&lt;p&gt;Accessing elements in a multi-dimensional list/array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; matrix = [
      [2, 4, 6],
      [9, 5, 7],
      [3, 8, 1]
    ]
&amp;gt;&amp;gt;&amp;gt; print(matrix[1][2])
&amp;gt;&amp;gt;&amp;gt; print(matrix[0][1])
7
4

&amp;gt;&amp;gt;&amp;gt; matrix = [
      [2, 4, 6],
      [9, 5, 7],
      [3, 8, 1]
    ]
&amp;gt;&amp;gt;&amp;gt; print(matrix[2][3])
#Returns an error for the index is out of range.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;List Functions and Methods/Actions&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;len() - Find the length of a list (number of items in a list).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; print(len(basket))
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.append() - Used to add a value to an original list.&lt;br&gt;
It modifies the list &lt;em&gt;inplace&lt;/em&gt; hence does not create a copy of the original list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.append(100)
&amp;gt;&amp;gt;&amp;gt; print(basket)
[1, 2, 3, 4, 5, 100]

&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; new_list = basket.append(100)
&amp;gt;&amp;gt;&amp;gt; print(basket)
&amp;gt;&amp;gt;&amp;gt; print(new_list)
[1, 2, 3, 4, 5, 100]
None

&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.append(100)
&amp;gt;&amp;gt;&amp;gt; new_list = basket
&amp;gt;&amp;gt;&amp;gt; print(basket)
&amp;gt;&amp;gt;&amp;gt; print(new_list)
[1, 2, 3, 4, 5, 100]
[1, 2, 3, 4, 5, 100]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.insert() - Used to insert a value anywhere in the list on a specific index.&lt;br&gt;
It too modifies the list &lt;em&gt;inplace&lt;/em&gt; hence does not create a copy of the original list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; new_list = basket.insert(4, 100)
&amp;gt;&amp;gt;&amp;gt; print(basket)
&amp;gt;&amp;gt;&amp;gt; print(new_list)
[1, 2, 3, 4, 100, 5]
None

&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.insert(4, 100)
&amp;gt;&amp;gt;&amp;gt; new_list = basket
&amp;gt;&amp;gt;&amp;gt; print(basket)
&amp;gt;&amp;gt;&amp;gt; print(new_list)
[1, 2, 3, 4, 100, 5]
[1, 2, 3, 4, 100, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.extend() - Used to append another list to the original list.&lt;br&gt;
It too modifies the list &lt;em&gt;inplace&lt;/em&gt; hence does not create a copy of the original list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; new_list = basket.extend([100, 101, 107])
&amp;gt;&amp;gt;&amp;gt; print(basket)
&amp;gt;&amp;gt;&amp;gt; print(new_list)
[1, 2, 3, 4, 5, 100, 101, 107]
None

&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.extend([100, 101, 107])
&amp;gt;&amp;gt;&amp;gt; new_list = basket
&amp;gt;&amp;gt;&amp;gt; print(basket)
&amp;gt;&amp;gt;&amp;gt; print(new_list)
[1, 2, 3, 4, 5, 100, 101, 107]
[1, 2, 3, 4, 5, 100, 101, 107]

numbers = [1, 2, 3, 4]
friends = ["Kelvin", "Karen", "Jim"]
friends.extend(numbers)
print(friends)
['Kelvin', 'Karen', 'Jim', 1, 2, 3, 4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.pop() - Automatically removes (pops off) the last element from the list or from the given index. It returns the element that has been popped off.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.pop()
&amp;gt;&amp;gt;&amp;gt; print(basket)
[1, 2, 3, 4]

&amp;gt;&amp;gt;&amp;gt; friends = ["Kelvin", "Karen", "Jim"]
&amp;gt;&amp;gt;&amp;gt; friends.pop()
&amp;gt;&amp;gt;&amp;gt; print(friends)
['Kelvin', 'Karen']

&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.pop(0)
&amp;gt;&amp;gt;&amp;gt; print(basket)
[2, 3, 4, 5]

&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.pop(2)
&amp;gt;&amp;gt;&amp;gt; print(basket)
[1, 2, 4, 5]

&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; new_list = basket.pop(4)
&amp;gt;&amp;gt;&amp;gt; print(new_list)
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.remove() - Removes an element/value from a list. Works 'inplace'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.remove(4)
&amp;gt;&amp;gt;&amp;gt; print(basket)
[1, 2, 3, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.clear() - Clears the entire list. Works 'inplace'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 5]
&amp;gt;&amp;gt;&amp;gt; basket.clear()
&amp;gt;&amp;gt;&amp;gt; print(basket)
[]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.index() - Used to check the index of an 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;&amp;gt;&amp;gt;&amp;gt; basket = ['a', 'b', 'c', 'd', 'e']
&amp;gt;&amp;gt;&amp;gt; print(basket.index('d'))
3

Checking from a specific index in the list.

&amp;gt;&amp;gt;&amp;gt; basket = ['a', 'b', 'c', 'd', 'e']
&amp;gt;&amp;gt;&amp;gt; print(basket.index('d', 0, 3)) #Checking from index 0 to index 3 (but not including index 3).
#returns an error as 'd' is in index 3 yet index 3 is not included in the range.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finding whether an element is or is not in a list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We use the keyword 'in' which returns whether True or False.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = ['a', 'b', 'c', 'd', 'e']
&amp;gt;&amp;gt;&amp;gt; print('d' in basket)
True

&amp;gt;&amp;gt;&amp;gt; basket = ['a', 'b', 'c', 'd', 'e']
&amp;gt;&amp;gt;&amp;gt; print('i' in basket)
False

&amp;gt;&amp;gt;&amp;gt; print('a' in 'My name is Mark')
True

&amp;gt;&amp;gt;&amp;gt; print('z' in 'What is the time?')
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.count() - Used to count the number of items an element appears 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;&amp;gt;&amp;gt;&amp;gt; basket = ['a', 'b', 'c', 'd', 'e']
&amp;gt;&amp;gt;&amp;gt; print(basket.count('d'))
1

&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 3, 4, 2, 5, 2]
&amp;gt;&amp;gt;&amp;gt; print(basket.count(2))
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.sort() - Used to sort the list in ascending order. If the list contains names, they are sorted in alphabetical order. Works 'inplace'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [5, 2, 3, 4, 1, 3, 2]
&amp;gt;&amp;gt;&amp;gt; basket.sort()
&amp;gt;&amp;gt;&amp;gt; print(basket)
[1, 2, 2, 3, 3, 4, 5]

&amp;gt;&amp;gt;&amp;gt; friends = ["Karen", "Toby", "Elijah"]
&amp;gt;&amp;gt;&amp;gt; friends.sort()
&amp;gt;&amp;gt;&amp;gt; print(friends)
['Elijah', 'Karen', 'Toby']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;sorted() - Used to sort the list in ascending order. If the list contains names, they are sorted in alphabetical order. Unlike the method x.sort(), sorted() is a function that produces a new array and hence does not work inplace.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; friends = ["Karen", "Toby", "Elijah"]
&amp;gt;&amp;gt;&amp;gt; print(sorted(friends))
['Elijah', 'Karen', 'Toby']

&amp;gt;&amp;gt;&amp;gt; basket = [5, 2, 3, 4, 1, 3, 2]
&amp;gt;&amp;gt;&amp;gt; print(sorted(basket))
[1, 2, 2, 3, 3, 4, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.copy() - Works the same as [:] by copying the entire list and creating a new one exactly like the original list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; friends = ["Karen", "Toby", "Elijah"]
&amp;gt;&amp;gt;&amp;gt; new_friends = friends.copy()
&amp;gt;&amp;gt;&amp;gt; print(new_friends)
['Karen', 'Toby', 'Elijah']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.reverse() - Used to reverse the elements in the list from the element in the last index to the element in the first index. Works 'inplace'.&lt;br&gt;
(It does not follow the ascending or any order; It just swaps the elements).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; friends = ["Karen", "Toby", "Elijah"]
&amp;gt;&amp;gt;&amp;gt; friends.reverse()
&amp;gt;&amp;gt;&amp;gt; print(friends)
['Elijah', 'Toby', 'Karen']

&amp;gt;&amp;gt;&amp;gt; numbers = [1, 5, 3, 8, 7]
&amp;gt;&amp;gt;&amp;gt; numbers.reverse()
&amp;gt;&amp;gt;&amp;gt; print(numbers)
[7, 8, 3, 5, 1]

&amp;gt;&amp;gt;&amp;gt; numbers = [1, 5, 3, 8, 7]
&amp;gt;&amp;gt;&amp;gt; numbers.sort()
&amp;gt;&amp;gt;&amp;gt; numbers.reverse()
&amp;gt;&amp;gt;&amp;gt; print(numbers)
[8, 7, 5, 3, 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Common List Patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reversing a list with list slicing&lt;/strong&gt;&lt;br&gt;
This creates a new list from the original, that is, it does not work inplace.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; numbers = [1, 5, 3, 8, 7]
&amp;gt;&amp;gt;&amp;gt; numbers.sort()
&amp;gt;&amp;gt;&amp;gt; numbers.reverse()
&amp;gt;&amp;gt;&amp;gt; print(numbers)
&amp;gt;&amp;gt;&amp;gt; print(numbers[::-1])
[8, 7, 5, 3, 1]
[1, 3, 5, 7, 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; You can reverse a list using list slicing (-1) or using the x.reverse() method as shown above. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;range()&lt;/strong&gt; - Generates a list of numbers from up to but not including the last number stated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print (list(range(1, 50)))
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49]

&amp;gt;&amp;gt;&amp;gt; print (list(range(50)))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49]

&amp;gt;&amp;gt;&amp;gt; print (list(range(51)))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49,
50]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Getting the length of a list&lt;/strong&gt; - Number of items in a list.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; basket = [1, 2, 6, 8, 4, 0]
&amp;gt;&amp;gt;&amp;gt; print(len(basket))
6

&amp;gt;&amp;gt;&amp;gt; names = ["Mark", "Enoch", "Vivian", "Yvonne", "Mercy"]
&amp;gt;&amp;gt;&amp;gt; print(len(names))
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;.join&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
This is a string method used to join items in a list with the given 'character'. It creates a new item and hence does not work inplace.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; sentence = '!'
&amp;gt;&amp;gt;&amp;gt; new_sentence = sentence.join(['hi', 'my', 'name', 'is', 'JOJO'])
&amp;gt;&amp;gt;&amp;gt; print(new_sentence)
hi!my!name!is!JOJO

&amp;gt;&amp;gt;&amp;gt; sentence = '.'
&amp;gt;&amp;gt;&amp;gt; new_sentence = sentence.join(['hi', 'my', 'name', 'is', 'JOJO'])
&amp;gt;&amp;gt;&amp;gt; print(new_sentence)
hi.my.name.is.JOJO

&amp;gt;&amp;gt;&amp;gt; sentence = ' '
&amp;gt;&amp;gt;&amp;gt; sen2 = ['hello', 'welcome', 'to', 'the', 'city']
&amp;gt;&amp;gt;&amp;gt; new_sentence = sentence.join(sen2)
&amp;gt;&amp;gt;&amp;gt; print(new_sentence)
hello welcome to the city

&amp;gt;&amp;gt;&amp;gt; new_sentence = '!'.join(['hi', 'my', 'name', 'is', 'JOJO'])
&amp;gt;&amp;gt;&amp;gt; print(new_sentence)
hi!my!name!is!JOJO

&amp;gt;&amp;gt;&amp;gt; new_sentence = ' '.join(['hi', 'my', 'name', 'is', 'JOJO'])
&amp;gt;&amp;gt;&amp;gt; print(new_sentence)
hi my name is JOJO
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;List Unpacking&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is assigning a variable to each item in a list. Works like multiple assigning of values in variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a,b,c = [1, 2, 3]
&amp;gt;&amp;gt;&amp;gt; print(a)
&amp;gt;&amp;gt;&amp;gt; print(b)
&amp;gt;&amp;gt;&amp;gt; print(c)
1
2
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In list unpacking, you can add more values, unpack the values assigned in the variables then store the remaining items in their own variable. You just add the * sign and the name of the variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a,b,c *other = [1, 2, 3, 4, 5, 6, 7, 8, 9]
&amp;gt;&amp;gt;&amp;gt; print(a)
&amp;gt;&amp;gt;&amp;gt; print(b)
&amp;gt;&amp;gt;&amp;gt; print(c)
&amp;gt;&amp;gt;&amp;gt; print(other)
1
2
3
[4, 5, 6, 7, 8, 9]

&amp;gt;&amp;gt;&amp;gt; a,b,c, *other, d = [1, 2, 3, 4, 5, 6, 7, 8, 9]
&amp;gt;&amp;gt;&amp;gt; print(a)
&amp;gt;&amp;gt;&amp;gt; print(b)
&amp;gt;&amp;gt;&amp;gt; print(c)
&amp;gt;&amp;gt;&amp;gt; print(other)
&amp;gt;&amp;gt;&amp;gt; print(d)
1
2
3
[4, 5, 6, 7, 8]
9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;f.) None type&lt;br&gt;
This is a special data type that represents the absence of values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; weapons = None
&amp;gt;&amp;gt;&amp;gt; print(weapons)
None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;g.) Tuples&lt;br&gt;
These are like lists but immutable data types. Data stored in tuples can never be changed eg. coordinates.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Can't add elements to it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can't erase elements from it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can't modify elements in it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tuples are also data structures.&lt;br&gt;
They use the parenthesis '()' to store data and can store data of different data types in a single tuple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 2, 4, 7, 5)
&amp;gt;&amp;gt;&amp;gt; print(my_tuple)
(1, 2, 4, 7, 5)

&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 2, 'a', True)
&amp;gt;&amp;gt;&amp;gt; print (my_tuple)
(1, 2, 'a', True)

&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 2, 4, 7, 5)
&amp;gt;&amp;gt;&amp;gt; print(my_tuple[3])
7

&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 2, 4, 7, 5)
&amp;gt;&amp;gt;&amp;gt; print(3 in my_tuple)
False

&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 2, 4, 7, 5)
&amp;gt;&amp;gt;&amp;gt; print(5 in my_tuple)
True

&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 2, 4, 7, 5)
&amp;gt;&amp;gt;&amp;gt; my_tuple[3] = 9
&amp;gt;&amp;gt;&amp;gt; print(my_tuple)
#returns an error as tuples cannot be modified
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Tuples can be sliced (similar to list slicing)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 2, 3, 4, 5)
&amp;gt;&amp;gt;&amp;gt; new_tuple = my_tuple[1:4]
&amp;gt;&amp;gt;&amp;gt; print(new_tuple)
(2, 3, 4)

&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 2, 3, 4, 5)
&amp;gt;&amp;gt;&amp;gt; new_tuple = my_tuple[1:2]
&amp;gt;&amp;gt;&amp;gt; print(new_tuple)
(2,)

&amp;gt;&amp;gt;&amp;gt; x, y, z, *other = (1, 2, 3, 4, 5)
&amp;gt;&amp;gt;&amp;gt; print(x)
&amp;gt;&amp;gt;&amp;gt; print(y)
&amp;gt;&amp;gt;&amp;gt; print(z)
&amp;gt;&amp;gt;&amp;gt; print(other)
1
2
3
[4, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tuples have two main methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;x.count()&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;x.index()&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 5, 3, 4, 5)
&amp;gt;&amp;gt;&amp;gt; print(my_tuple.count(5))
2

&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 5, 3, 4, 5)
&amp;gt;&amp;gt;&amp;gt; print(my_tuple.index(4))
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To get the length of a tuple:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_tuple = (1, 5, 3, 4, 5)
&amp;gt;&amp;gt;&amp;gt; print(len(my_tuple))
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;A list of tuples:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; coordinates = [(4, 5), (6, 7), (80, 34)]
&amp;gt;&amp;gt;&amp;gt; print(coordinates)
[(4, 5), (6, 7), (80, 34)]

&amp;gt;&amp;gt;&amp;gt; coordinates = [(4, 5), (6, 7), (80, 34)]
&amp;gt;&amp;gt;&amp;gt; print(coordinates[1])
(6, 7)

&amp;gt;&amp;gt;&amp;gt; coordinates = [(4, 5), (6, 7), (80, 34)]
&amp;gt;&amp;gt;&amp;gt; print(coordinates[1][1])
7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;h.) Dictionaries&lt;br&gt;
This is a special data structure that allows one to organize or store data in unordered key-value pairs. It uses curly braces '{}'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dictionary = {
   'key' : value,
   'key' : value
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key must always be unique (shouldn't be repeated).&lt;br&gt;
To access the value, we use the key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : 1,
      'b' : 2,
      'x' : 4
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict)
{'a': 1, 'b': 2, 'x': 3}

&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : 1,
      'b' : 2,
      'x' : 4
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict['b'])
2

&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : 1,
      'b' : 2
      'x' : 4
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict['c'])
#returns an error for the key is not defined.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; Elements in a dictionary are stored in different memory locations which are not necessarily in order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : 1,
      'b' : 2,
      'x' : 4
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict)
{'a': 1, 'b': 2, 'x': 3}

At times the output may be as shown below.

&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : 1,
      'b' : 2,
      'x' : 4
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict)
{'x': 4, 'a': 1, 'b': 2}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dictionary keys can store values of different data types (same as lists and tuples).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : [1, 2, 3],
      'b' : "hello",
      'x' : True,
      't' : 5
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict)
{'a': [1, 2, 3], 'b': 'hello', 'x': True, 't': 5}

&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : [1, 2, 3],
      'b' : "hello",
      'x' : True,
      't' : 5
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict['a'])
[1, 2, 3]

&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : [1, 2, 3],
      'b' : "hello",
      'x' : True,
      't' : 5
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict['a'][1])
2

&amp;gt;&amp;gt;&amp;gt; my_dict = {
      'a' : [1, 2, 3],
      'b' : "hello",
      'x' : True,
      't' : 5
      }
&amp;gt;&amp;gt;&amp;gt; print(my_dict['b'][4])
o
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;A dictionary in a list.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_list = [
       {
        'a' : [1, 2, 3],
        'b' : "hello",
        'x' : True,
        't' : 5
        },

       {
        'a' : [4, 5, 6],
        'b' : "welcome",
        'x' : False,
        't' : 5
       }
    ]
&amp;gt;&amp;gt;&amp;gt; print(my_list[0]['a'][2])
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Dictionary Keys&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Dictionary keys are immutable types and should be unique. This means that a string, a number, a tuple and a Boolean can be a key while a list cannot.&lt;br&gt;
&lt;code&gt;Note:&lt;/code&gt; When one re-assigns a key to another value, the original value in the key is overwritten.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; dictionary = {
         123 : [1, 2, 5, 6],
         True : 'hello',
         'a' : ('a', 't', 'u'),
         [100] : False
     }
&amp;gt;&amp;gt;&amp;gt; print (dictionary[100])
#returns an error as a list is mutable and hence cannot be used as a key.

&amp;gt;&amp;gt;&amp;gt; dictionary = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         '123' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print(dictionary['123'])
('a', 't', 'u')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Dictionary Methods&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;x.get() - A method used to check whether a key is present in a dictionary. At times it returns a default value given if a key is missing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print(user.get('age'))
None

&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print(user.get('age', 55))
55

&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u'),
         'age' : 20
     }
&amp;gt;&amp;gt;&amp;gt; print(user.get('age', 55))
20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;A second way of creating a dictionary:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By using the keyword 'dict(key = value)'.&lt;br&gt;
The key cannot be an expression, that is, it should be a variable when using 'dict'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user2 = dict(name = 'John')
&amp;gt;&amp;gt;&amp;gt; print(user2)
{'name': 'John'}

&amp;gt;&amp;gt;&amp;gt; user2 = dict(name = 'John', name2 = 'Mark')
&amp;gt;&amp;gt;&amp;gt; print(user2)
{'name': 'John', 'name2': 'Mark'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;'in' keyword can also be used in dictionaries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It returns either True or False on whether a key is present or absent in a dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print('size' in user)
False

&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print('basket' in user)
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.keys() - Used to check whether a specific key is present in a dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print('123' in user.keys())
True

&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print('age' in user.keys())
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.values() - Used to check whether a specific value is present in a dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print('hello' in user.values())
True

&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print(('a', 't', 'u') in user.values())
True

&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print([1, 2, 6, 5] in user.values())
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.items() - Returns the entire items in a dictionary as tuples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print(user.items())
dict_items([('123', [1, 2, 5, 6]), (True, 'hello'), ('basket', ('a', 't', 'u'))])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.clear() - clears the dictionary and returns an empty dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; print(user.clear())
None

&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; user.clear()
&amp;gt;&amp;gt;&amp;gt; print(user)
{}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.copy() - creates a copy of a dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u')
     }
&amp;gt;&amp;gt;&amp;gt; user2 = user.copy()
&amp;gt;&amp;gt;&amp;gt; print(user2)
{'123': [1, 2, 5, 6], True: 'hello', 'basket': ('a', 't', 'u')}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.pop() - Removes key with its value from the dictionary and returns the value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u'),
         'age' : 20
     }
&amp;gt;&amp;gt;&amp;gt; user.pop('age')
&amp;gt;&amp;gt;&amp;gt; print(user)
20
{'123': [1, 2, 5, 6], True: 'hello', 'basket': ('a', 't', 'u')}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.popitem() - Removes a random pair of key-value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u'),
         'age' : 20
     }
&amp;gt;&amp;gt;&amp;gt; user.popitem()
&amp;gt;&amp;gt;&amp;gt; print(user)
('age', 20)
{'123': [1, 2, 5, 6], True: 'hello', 'basket': ('a', 't', 'u')}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.update() - Used to update the keys in the dictionary or by adding a new key and value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u'),
         'age' : 20
     }
&amp;gt;&amp;gt;&amp;gt; user.update({'age' : 55})
&amp;gt;&amp;gt;&amp;gt; print(user)
{'123': [1, 2, 5, 6], True: 'hello', 'basket': ('a', 't', 'u'), 'age': 55}

&amp;gt;&amp;gt;&amp;gt; user = {
         '123' : [1, 2, 5, 6],
         True : 'hello',
         'basket' : ('a', 't', 'u'),
         'age' : 20
     }
&amp;gt;&amp;gt;&amp;gt; user.update({'age2' : 55})
&amp;gt;&amp;gt;&amp;gt; print(user)
{'123': [1, 2, 5, 6], True: 'hello', 'basket': ('a', 't', 'u'), 'age': 20, 'age2': 55}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;i.) Sets&lt;br&gt;
These are an unordered collection of unique objects. It uses curly brackets and returns only the unique objects.&lt;br&gt;
&lt;/p&gt;

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

&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5, 5}
&amp;gt;&amp;gt;&amp;gt; my_set.add(2)
&amp;gt;&amp;gt;&amp;gt; my_set.add(100)
&amp;gt;&amp;gt;&amp;gt; print(my_set)
{1, 2, 3, 4, 5, 100}

&amp;gt;&amp;gt;&amp;gt; my_list = [1, 2, 2, 3, 5, 5]
&amp;gt;&amp;gt;&amp;gt; print(set(my_list))
{1, 2, 3, 5}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Objects in a set are not indexed and hence cannot be accessed using an index.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5, 5}
&amp;gt;&amp;gt;&amp;gt; print(my_set[0])
#returns an error as items cannot be accessed using indexes in sets

&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5, 5}
&amp;gt;&amp;gt;&amp;gt; print(1 in my_set)
True

&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5, 5, 7, 7}
&amp;gt;&amp;gt;&amp;gt; print(6 in my_set)
False

&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5, 5, 7, 7}
&amp;gt;&amp;gt;&amp;gt; print(len(my_set))
6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Converting a set to a list.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5, 5, 7, 7}
&amp;gt;&amp;gt;&amp;gt; print(list(my_set))
[1, 2, 3, 4, 5, 7]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.copy - Copies a set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5, 5, 7, 7}
&amp;gt;&amp;gt;&amp;gt; new_set = my_set.copy()
&amp;gt;&amp;gt;&amp;gt; my_set.clear()
&amp;gt;&amp;gt;&amp;gt; print(new_set)
&amp;gt;&amp;gt;&amp;gt; print(my_set)
{1, 2, 3, 4, 5, 7}
set()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Methods in sets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;x.difference() - Finds the difference of two sets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set.difference(your_set))
{1, 2, 3}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.discard() - Removes an element from a set if it is a member. Works inplace.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;x.difference_update() - Removes all elements of another set from the previous set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set.difference_update(your_set))
{1, 2, 3}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.intersection() - Returns the common values in both sets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set.intersection(your_set))
{4, 5}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; You can also use the &amp;amp; symbol for intersection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set &amp;amp; your_set)
{4, 5}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.isdisjoint() - Returns either False or True if they have or don't have common values respectively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3, 4, 5}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set.isdisjoint(your_set))
False

&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set.isdisjoint(your_set))
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.union() - Returns the union of two sets and removes the duplicates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set.union(your_set))
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Note:&lt;/code&gt; For union, you can also use the | symbol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {1, 2, 3}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set | your_set)
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.issubset() - Returns either True or False on whether a set is a subset of the other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {4, 5}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set.issubset(your_set))
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x.issuperset() - Returns either True of False on whether a set is a superset of the other.&lt;br&gt;
&lt;em&gt;Superset is the opposite of subset.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; my_set = {4, 5}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(my_set.issuperset(your_set))
False

&amp;gt;&amp;gt;&amp;gt; my_set = {4, 5}
&amp;gt;&amp;gt;&amp;gt; your_set = {4, 5, 6, 7, 8, 9, 10}
&amp;gt;&amp;gt;&amp;gt; print(your_set.issuperset(my_set))
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;blockquote&gt;
&lt;p&gt;Below are attached links to more resources on the topics discussed above:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;More on &lt;a href="https://www.youtube.com/watch?v=PZRI1IfStY0"&gt;Floating-point-numbers&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.programiz.com/python-programming/modules/math"&gt;Math-Functions-in-Python&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/python-int-function/"&gt;Base-Numbers&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/python/python_ref_keywords.asp"&gt;Python-Keywords&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.python.org/3/library/functions.html"&gt;Built-in-Functions&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/python/python_ref_string.asp"&gt;Python-String-Methods&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/python/python_ref_list.asp"&gt;List-Methods&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/python/python_ref_dictionary.asp"&gt;Dictionary-Methods&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/python/python_ref_tuple.asp"&gt;Tuple-Methods&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/python/python_ref_set.asp"&gt;Sets-Methods&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Congratulations on completing the first milestone &lt;em&gt;&lt;strong&gt;Python Basics Part1&lt;/strong&gt;&lt;/em&gt;.&lt;br&gt;
To recap, we have covered variables and data types in Python which includes a few data structures in Python.&lt;br&gt;
Next, in &lt;a href="https://dev.to/gateremark/python-from-the-word-go-pt2-31k0"&gt;&lt;em&gt;Python Basics Pt2&lt;/em&gt;&lt;/a&gt;, we gonna be diving more into Python working with control structures, loops and many more...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;See you Then!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>career</category>
    </item>
    <item>
      <title>The Ultimate Guide to Getting Started in Data Science.</title>
      <dc:creator>Mark Gatere</dc:creator>
      <pubDate>Sat, 02 Apr 2022 00:07:49 +0000</pubDate>
      <link>https://dev.to/gateremark/the-ultimate-guide-to-getting-started-in-data-science-2c7a</link>
      <guid>https://dev.to/gateremark/the-ultimate-guide-to-getting-started-in-data-science-2c7a</guid>
      <description>&lt;p&gt;&lt;em&gt;"Whenever there's a buzzword and a 'complex' subject matter, it's usually good to start with the definition..."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Data Science?&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;The term Data Science, which was introduced around the 1980s remains confusing for many people even now.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;"Data Science is not about making complicated models; it's not about making awesome visualizations; it's not about writing code..." - &lt;a href="https://www.youtube.com/watch?v=xC-c7E5PK0Y"&gt;Joma Tech&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then what is it?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#it's up to you

if YouWant == True:
   YouCan
else:
   YouCan't
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;History of Data Science&lt;/strong&gt;&lt;br&gt;
Early in the days, before Data Science became &lt;a href="https://www.hbs.edu/faculty/Pages/item.aspx?num=43110"&gt;the sexiest job of the 21st century&lt;/a&gt;, the popular term was Data Mining. In the article '&lt;a href="https://ojs.aaai.org//index.php/aimagazine/article/view/1230"&gt;From Data Mining to Knowledge Discovery in Databases&lt;/a&gt;' in 1996, Usama Fayyad, Gregory Piatetsky-Shapiro and Padhraic Smyth referred to Data Mining as the overall process of discovering useful knowledge and patterns from data by use of specific algorithms.&lt;br&gt;
In 2001, William S. Cleveland decided to combine Computer Science and Data Mining by making statistics a lot more technical believing that it would expand the possibilities of Data Mining and produce a powerful force of innovation.&lt;br&gt;
Nowadays, you can take advantage of computing power for statistics which is now known as Data Science.&lt;br&gt;
&lt;code&gt;Data Science is an interdisciplinary field where its true foundations are in Statistics, Mathematics, Computer Science, and business too&lt;/code&gt;&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%2F2tkc6fhpogohfir9ye8x.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%2F2tkc6fhpogohfir9ye8x.png" alt="Data Science" width="800" height="725"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"I wanna become a Data Scientist, where should I start?..."&lt;br&gt;
Many would say statistics, others math, others programming... &lt;br&gt;
Best answer? Let's find out.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Assuming Data Science is an Ocean...&lt;/em&gt;&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%2Fnisz38j5s9lowetiw5ij.jpg" 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%2Fnisz38j5s9lowetiw5ij.jpg" alt="The Ocean" width="800" height="933"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 - Sail around the Sea of 𝗣𝗿𝗼𝗯𝗮𝗯𝗶𝗹𝗶𝘁𝘆 &amp;amp; 𝗦𝘁𝗮𝘁𝗶𝘀𝘁𝗶𝗰𝘀 📈
&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%2Frh8kfa9pgotm50k6a3ia.jpg" 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%2Frh8kfa9pgotm50k6a3ia.jpg" alt="Probability and Statistics" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Someone once said, "A Data Scientist is just an overpaid Statistician". How true is that? &lt;code&gt;Statistics is the science concerned with developing and studying methods for collecting, analyzing, interpreting and presenting empirical data&lt;/code&gt;. In both Data Science and Statistics, our main concern is Data. How we get insights from the data collected, the modes of collecting it, manipulating it... (Data Wrangling).&lt;br&gt;
Hence, when equipped with the Probability and Statistics tools, one will find it easy working with the data, finding its correlation, and getting useful insights from it.&lt;/p&gt;

&lt;p&gt;There are awesome free resources online and awesome platforms to learn Probability and Statistics including &lt;a href="https://www.coursera.org/learn/probability-statistics"&gt;Probability and Statistics: To p or not to p?&lt;/a&gt; on Coursera, &lt;a href="https://www.edx.org/course/statistical-learning"&gt;Statistical Learning&lt;/a&gt; on edX and an awesome book by Gareth James, Daniela Witten, Trevor Hastie and Rob Tibshirani, &lt;a href="https://www.statlearning.com/"&gt;An Introduction to Statistical Learning&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 - Drift to the Bay of Computer Science 🖥️
&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%2Fgyi37jrftcwuo1af9e22.jpg" 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%2Fgyi37jrftcwuo1af9e22.jpg" alt="Code" width="540" height="217"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Do you know how to code?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There are two main programming languages for Data Science (Python and R). Python unlike R is more popular and highly flexible, helping one transition to different domains like Web Development, Web Scraping, Embedded Systems etc.&lt;/p&gt;

&lt;p&gt;There are several online free resources to start your Python Programming journey, which includes the most popular Python Programming tutorial on &lt;a href="https://www.youtube.com/watch?v=rfscVS0vtbw"&gt;YouTube&lt;/a&gt;&lt;br&gt;
Platforms like &lt;a href="https://www.datacamp.com/"&gt;DataCamp&lt;/a&gt; and &lt;a href="https://www.coursera.org/"&gt;Coursera&lt;/a&gt; too have awesome courses to get you started in programming.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ready to venture into deeper and stormier waters 🌊?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 - Machine Learning and Deep Learning
&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%2Ff4e75xnufizv3k074s4m.jpg" 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%2Ff4e75xnufizv3k074s4m.jpg" alt="Machine Learning" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Recently, I published an article on &lt;a href="https://gateremark.medium.com/understanding-machine-learning-and-its-basic-workflow-1-fe85a412bb21"&gt;Understanding Machine Learning and its Basic Workflow&lt;/a&gt; where I've gone deeper into explaining what Machine Learning is and its Complete Workflow in the Real-World. &lt;br&gt;
In Machine Learning, you'll learn how to build models and use them for prediction, and also the math of what happens under the hood.&lt;br&gt;
For more on Machine Learning and Deep Learning, I find &lt;a href="https://www.mrdbourke.com/"&gt;Daniel Bourke&lt;/a&gt;'s blog enriched with useful information which includes his Machine Learning Roadmap clip on &lt;a href="https://www.youtube.com/watch?v=pHiMN_gy9mk&amp;amp;t=2489s"&gt;YouTube&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Wooow!! We've just discussed everything in a nutshell;&lt;/em&gt;&lt;br&gt;
 Where can I find the rest?...&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%2Fst6cbmc5z0fw6ok0rb7k.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%2Fst6cbmc5z0fw6ok0rb7k.PNG" alt="Google" width="800" height="403"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;&amp;gt;Google has it all in store for you!!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, &lt;a href="https://365datascience.com/"&gt;365 Data Science&lt;/a&gt; are offering a free "Starting A Career In Data Science:&lt;a href="https://discover.365datascience.com/data-science-career-guide-yt/?utm_medium=social&amp;amp;utm_source=youtube&amp;amp;utm_campaign=explained-in-5&amp;amp;utm_content=what%20is%20data%20science%20explained%20in%205%20&amp;amp;utm_term=description"&gt;Ultimate Guide&lt;/a&gt;" to help you understand more concepts in the field of 'Data' including Data Engineers and Data Analyst and also explaining their roles in depths.&lt;br&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%2Fk826vjd7folundwy0j4e.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%2Fk826vjd7folundwy0j4e.PNG" alt="The End" width="800" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>data</category>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
