<?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: Mukumbuta</title>
    <description>The latest articles on DEV Community by Mukumbuta (@mukumbuta).</description>
    <link>https://dev.to/mukumbuta</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%2F563640%2F466d8882-bdb5-4576-9dc8-e4e1a8424944.jpg</url>
      <title>DEV Community: Mukumbuta</title>
      <link>https://dev.to/mukumbuta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mukumbuta"/>
    <language>en</language>
    <item>
      <title>DevOps - NGINX Configuration</title>
      <dc:creator>Mukumbuta</dc:creator>
      <pubDate>Thu, 30 Jan 2025 02:04:31 +0000</pubDate>
      <link>https://dev.to/mukumbuta/devops-nginx-configuration-b4n</link>
      <guid>https://dev.to/mukumbuta/devops-nginx-configuration-b4n</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As part of my DevOps learning journey, I was tasked with setting up and configuring NGINX on a fresh Ubuntu server. This exercise tested my ability to deploy a simple web server, configure it to serve a custom webpage and make it accessible to the public. In this blog post, I will walk you through my approach, the challenges I faced, and what I learned from the experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Approach &amp;amp; Steps Taken&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 0: Setting Up a Domain Name&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The first step I took was to buy a domain name from godaddy.com, created a subdomain and pointed it to the VPS.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 1: Setting Up an Ubuntu Server&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The second step was to get an Ubuntu server up and running. I chose &lt;strong&gt;Namecheap VPS&lt;/strong&gt; with the following specifications:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OS:&lt;/strong&gt; Ubuntu 22.04 LTS
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CPU:&lt;/strong&gt; 8 CPU
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RAM:&lt;/strong&gt; 12GB
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage:&lt;/strong&gt; 32GB
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public IP:&lt;/strong&gt; Assigned automatically
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I connected to the server using SSH:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh myusername@my-server-ip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2: Installing NGINX&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once inside the server, I updated the package list and installed NGINX:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
sudo apt install nginx -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To verify that NGINX was installed and running, I used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Opening &lt;code&gt;http://server-IP/&lt;/code&gt; in a browser confirmed that NGINX was serving its default welcome page.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 3: Configuring NGINX to Serve a Custom Web Page&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The next step was to create an Nginx server block for this specific task.&lt;br&gt;
A server block in Nginx is a configuration section that defines how Nginx handles requests for a specific domain or IP address.&lt;/p&gt;

&lt;p&gt;I then created a symbolic link in Nginx by linking the configuration file from /etc/nginx/sites-available/ to /etc/nginx/sites-enabled/. This allows Nginx to recognize and use the configuration when it reloads.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ln -s /etc/nginx/sites-available/devops /etc/nginx/sites-enabled/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The folowing step was to replace the default NGINX page with a custom one. I created a file &lt;strong&gt;index.html&lt;/strong&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /var/www/html/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I then coded in the appropriate HTML according to the task.&lt;br&gt;
After saving the file (&lt;code&gt;CTRL + O&lt;/code&gt;, then &lt;code&gt;Enter&lt;/code&gt;, then &lt;code&gt;X&lt;/code&gt;), I restarted NGINX to apply the changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visiting &lt;code&gt;http://server.gateway.tumingle.com/&lt;/code&gt; in a browser now displayed the custom message.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 4: Configuring Firewall for Public Access&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To ensure that my server was accessible from the internet, I checked the firewall settings and allowed HTTP traffic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This confirmed that traffic on &lt;strong&gt;port 80&lt;/strong&gt; was open.&lt;/p&gt;

&lt;p&gt;The last step was to issue an SSL certificate using certbot/nginx combination using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot --nginx -d server.gateway.tumingle.com.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I could view the site over HTTPS.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Challenges &amp;amp; How I Overcame Them&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. NGINX Not Running After Installation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;At first, NGINX failed to start. Running &lt;code&gt;sudo systemctl status nginx&lt;/code&gt; showed a &lt;strong&gt;port conflict&lt;/strong&gt;. The issue was caused by another web service running on port 80. I resolved it by stopping the conflicting service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl stop apache2
sudo systemctl disable apache2
sudo systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;2. Firewall Blocking HTTP Requests&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Even after configuring NGINX, my site was inaccessible. Checking the firewall rules (&lt;code&gt;sudo ufw status&lt;/code&gt;) revealed that &lt;strong&gt;port 80 was not open&lt;/strong&gt;. Enabling the necessary firewall rules fixed this.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. HTML Page Not Updating&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;After editing &lt;code&gt;index.html&lt;/code&gt;, my browser still showed the old page. This was due to caching. I cleared the cache with &lt;code&gt;CTRL + SHIFT + R&lt;/code&gt; and also restarted NGINX:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;What I Learned from This Experience&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Understanding Web Server Basics&lt;/strong&gt; – I learned how to install, configure, and manage NGINX, which is a fundamental skill for DevOps engineers.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Working with Firewalls&lt;/strong&gt; – Managing firewall rules was a key takeaway, ensuring my server was accessible while maintaining security.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Troubleshooting and Debugging&lt;/strong&gt; – Debugging issues with services like NGINX, checking logs, and resolving conflicts helped improve my problem-solving skills.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud and Server Administration&lt;/strong&gt; – Setting up a cloud-based virtual machine, securing it, and hosting a web application is essential knowledge for anyone entering the DevOps field.
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;How This Task Contributes to My Professional Growth&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This exercise gave me hands-on experience with &lt;strong&gt;NGINX deployment&lt;/strong&gt;, an essential skill for &lt;strong&gt;DevOps Engineers&lt;/strong&gt;. It also reinforced my ability to troubleshoot issues and work with &lt;strong&gt;Linux servers&lt;/strong&gt;, which are crucial in modern cloud environments.&lt;/p&gt;




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

&lt;p&gt;Completing the &lt;strong&gt;DevOps Stage 0 - NGINX Configuration&lt;/strong&gt; task was a valuable learning experience. It reinforced my understanding of &lt;strong&gt;web server deployment, Linux administration, and troubleshooting&lt;/strong&gt;. This hands-on practice has prepared me for more advanced &lt;strong&gt;DevOps and cloud computing&lt;/strong&gt; challenges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Steps:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy a similar setup using &lt;strong&gt;Docker&lt;/strong&gt; to containerize the application.
&lt;/li&gt;
&lt;li&gt;Explore &lt;strong&gt;load balancing&lt;/strong&gt; with NGINX for handling multiple requests efficiently.
&lt;/li&gt;
&lt;li&gt;Automate the setup using &lt;strong&gt;Ansible or Terraform&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This task has been an exciting first step in my DevOps journey, and I look forward to learning more! 🚀  &lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;What’s Next for You?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Have you ever set up NGINX on a server? What challenges did you face? Let me know in the comments!&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://hng.tech/hire/linux-developers" rel="noopener noreferrer"&gt;Linux Developers&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hng.tech/hire/devops-engineers" rel="noopener noreferrer"&gt;DevOps Engineers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>How to Use Git-flow in Your Workflow</title>
      <dc:creator>Mukumbuta</dc:creator>
      <pubDate>Wed, 31 Aug 2022 22:41:23 +0000</pubDate>
      <link>https://dev.to/mukumbuta/how-to-use-git-flow-in-your-workflow-268n</link>
      <guid>https://dev.to/mukumbuta/how-to-use-git-flow-in-your-workflow-268n</guid>
      <description>&lt;p&gt;Hi.&lt;br&gt;
By now, am sure you know there are two principle ways to manage software projects and and optimize a team's workflow in GIT, i.e, &lt;code&gt;Git-Flow&lt;/code&gt; and &lt;code&gt;Github Flow&lt;/code&gt;, just in case you forgot.&lt;br&gt;
In this article I will dwell on how to use Git-Flow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git-flow&lt;/strong&gt; is simply a git branching model in which instead of having just one main branch, we can have two branches &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;development&lt;/code&gt;. &lt;br&gt;
That sounds pleasant, Yes? &lt;br&gt;
I know, that's why I should be quick to mention that it has some paticluar use cases. According to &lt;em&gt;luca mezzalira (2014)&lt;/em&gt;, Git-flow is suggested to be used when your software has the concept of &lt;code&gt;release&lt;/code&gt; because it’s not the best decision when you work in &lt;strong&gt;Continuous Delivery&lt;/strong&gt; or &lt;strong&gt;Continuous Deployment&lt;/strong&gt; environment where this concept is missing.&lt;/p&gt;

&lt;p&gt;In Git-flow: &lt;br&gt;
&lt;code&gt;main&lt;/code&gt; tracks officail release history whereas, &lt;code&gt;development&lt;/code&gt; allows for the integration of feature branches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TIP:&lt;/strong&gt; Tag all commits to the main branch with version numbers.&lt;/p&gt;

&lt;p&gt;First of all one developer creates an empty develope branch and pushes it to the server.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git branch development`
`$ git push -u origin development`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  How to make development branch the base branch
&lt;/h1&gt;

&lt;p&gt;To change the base branch from &lt;code&gt;main&lt;/code&gt; to &lt;code&gt;devlopement&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Head over to github.com&lt;/li&gt;
&lt;li&gt;On your repository, head over to settings&lt;/li&gt;
&lt;li&gt;Click on &lt;code&gt;Branches&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Click on the &lt;code&gt;forward and reverse arrows&lt;/code&gt; icon&lt;/li&gt;
&lt;li&gt;Choose &lt;code&gt;developement&lt;/code&gt;in the drop-down menu&lt;/li&gt;
&lt;li&gt;Select 'I understand...'&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Congratulations! You have just changed the base braanch of your respository from &lt;code&gt;main&lt;/code&gt; to &lt;code&gt;development&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, other devs can then clone the central repository and create a tracking branch for &lt;code&gt;development&lt;/code&gt;&lt;br&gt;
Instead of branching off of &lt;code&gt;main&lt;/code&gt;, feature branches branch off &lt;code&gt;development&lt;/code&gt;.&lt;br&gt;
That is to say, &lt;code&gt;development&lt;/code&gt; is now the parent of feature branches.&lt;br&gt;
When a feature is complete, the feature branch is merged back into &lt;code&gt;development&lt;/code&gt;(This is what is known as 'Feature Branch Workflow').&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spoiler alert:&lt;/strong&gt; Feature branches must never interact directly with &lt;code&gt;main&lt;/code&gt;. &lt;/p&gt;
&lt;h1&gt;
  
  
  How to create a feature branch
&lt;/h1&gt;

&lt;p&gt;To create a feature branch, head over to your terminal and enter the following commands:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git checkout developement`
`$ git checkout -b feture_branch_name`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Or, you can use the git-flow extention library like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`git flow feature start feature_branch_name`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can then continue with the normal usage of Git.&lt;br&gt;
When dvelopement work on a feature is complete, it's now time to merge &lt;code&gt;feature_branch_name&lt;/code&gt; into &lt;code&gt;development&lt;/code&gt; like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git checkout dvelopement`
`$ git merge feature_branch_name`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Or using the git-flow extention like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git flow feature finish feature_branch_name`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now assuming we have a repository already setup with a main branch, we can demonstrate Feature Branch Flow like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git checkout main`
`$ git checkout -b development`
`$ git checkout -b feature_branch_name`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then run the following commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git checkout development`
`$ git merge feature_branch_name`
`$ git checkout main`
`$ git merge development`
`$ git branch -d feature_branch_name`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Release branch
&lt;/h1&gt;

&lt;p&gt;Once development has acquired enough features for a release, we can then fork a &lt;code&gt;release&lt;/code&gt; branch off of &lt;code&gt;development&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The beauty of using a dedicated branch to prepare releases makes it possible for one team to polish the current release while another team continues working on features for the next release.&lt;/p&gt;

&lt;p&gt;Release branches are based on the development branch. Below are a series of commands for creating a release branch:&lt;/p&gt;

&lt;p&gt;Without the git-flow extensions:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git checkout develop`
` $ git checkout -b release/0.1.0`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When using the git-flow extensions:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git flow release start 0.1.0`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You should be able to see some text that goes something like: "Switched to a new branch 'release/0.1.0'"&lt;/p&gt;

&lt;p&gt;You can now merge release branch into main and development and delete the branch. &lt;/p&gt;

&lt;p&gt;To finish a release branch, use the following methods:&lt;/p&gt;

&lt;p&gt;Without the git-flow extensions:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git checkout main`
`$ git merge release/0.1.0`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With the git-flow extension:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ git flow release finish '0.1.0'`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That's it!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Python For Web Development.</title>
      <dc:creator>Mukumbuta</dc:creator>
      <pubDate>Wed, 04 May 2022 10:42:38 +0000</pubDate>
      <link>https://dev.to/mukumbuta/mastering-python-for-web-development-5bad</link>
      <guid>https://dev.to/mukumbuta/mastering-python-for-web-development-5bad</guid>
      <description>&lt;p&gt;Python, is a practical language, and so practice is the major key for any aspiring developer to excel at programming in python. Python offers a concise and clear syntax which is easy to write and understand. Most developers and learners prefer Python for web development since it is a very powerful tool which has been used to back some of the world's most common products and services. Python offers many frameworks used in web developments such as Django, Flask, Cherrypy, Pyramid, that has been used to power some of the most successful websites such as Google, Netflix, NASA and many more.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Why Use Python For Web Development.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Django is published under BSD license, which assures the web applications can be used and modified freely without experiencing problems. It is free and open source.&lt;/li&gt;
&lt;li&gt; Django integrates a lot of efficient ways to perform unit tests.&lt;/li&gt;
&lt;li&gt; Django is fully customizable, developers can adapt to it easily by creating modules or overridden framework methods.&lt;/li&gt;
&lt;li&gt; Uses the Don't Repeat Yourself (DRY) principle which keeps the code simple and clear without having to copy/paste the same code elsewhere.&lt;/li&gt;
&lt;li&gt; Using python in this framework allows you to have benefits from all Python libraries and assures a very good readability.&lt;/li&gt;
&lt;li&gt; Django is supported by a good community which means that you can easily resolve issues and fix bugs quickly as a result of many code examples that shows good practices.
Django Framework
Django is a high-level python web framework that allows rapid development and clean practical design which was released in 2005 and named after a jazz guitarist Django Reinhardt. It was first started in 2003 by Adrian Holovaty and Simon Willison as an internal project at Lawrence Journal-World newspaper and was released in July, 2005. Using Django it is easier to build a better web app faster and with less code plus its free and open source.
&lt;strong&gt;Some of the Features of Django&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Complete&lt;/strong&gt;: Strives to provide almost everything that developers require to help them develop their sites from consistent design patterns to extensive updated documentations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Versatile&lt;/strong&gt;: Some organizations uses Django to build all sort of things from content management system to social networks to scientific computing platforms to new sites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Secure&lt;/strong&gt;: Emphasizes on security by assisting developers to avoid many common mistakes by providing a framework to protect the website automatically. Also gives a secure way to manage user accounts and passwords.&lt;br&gt;
&lt;strong&gt;Scalable&lt;/strong&gt;: Many of the busiest websites uses Django's ability to quickly and flexibly scale to meet the heaviest traffic demands.&lt;br&gt;
&lt;strong&gt;Maintainable&lt;/strong&gt;: Applies design principles and patterns that encourage the creation of maintainable and reusable code. By making use of Don't Repeat Yourself (DRY) principle so there is no unnecessary duplication, reducing the amount of code.&lt;br&gt;
&lt;strong&gt;Portable&lt;/strong&gt;: written in Python which runs on multiple platforms including Windows, Linux, Mac OS applications plus Django is well supported by many web-hosting providers that provides specific infrastructure and documentation for hosting Django sites.&lt;br&gt;
&lt;strong&gt;Django Installation Process&lt;/strong&gt;&lt;br&gt;
In order to be able to use Django, you need to install the following Software:&lt;br&gt;
• Python&lt;br&gt;
• PIP which facilitates the installation of Django and other important packages&lt;br&gt;
• Django&lt;br&gt;
• Virtual environment&lt;br&gt;
Installation of Python&lt;br&gt;
Depending on the operating system, Windows, Unix/Linux and Mac OS Python can be installed on each operating system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install PIP&lt;/strong&gt;&lt;br&gt;
PIP is important as it handles the packages installation, performs updates, and removes all the Python package extensions.&lt;br&gt;
Windows Download it from Here Then you install PIP from executable and remember to choose the correct python installation folder.&lt;br&gt;
Unix/Linux Run the following commands to be able to install PIP.&lt;br&gt;
root: wget &lt;a href="https://raw.github.com/pypa/pip/master/contrib/get-pip.py" rel="noopener noreferrer"&gt;https://raw.github.com/pypa/pip/master/contrib/get-pip.py&lt;/a&gt;&lt;br&gt;
root: python3 get-pip.py&lt;br&gt;
Mac OS Open up your terminal and run the get-pip.py file as shown below.&lt;br&gt;
$ curl -O &lt;a href="https://raw.github.com/pypa/pip/master/contrib/get-pip.py" rel="noopener noreferrer"&gt;https://raw.github.com/pypa/pip/master/contrib/get-pip.py&lt;/a&gt;&lt;br&gt;
$ sudo python3 get-pip.py&lt;br&gt;
Note that: To confirm whether pip is installed in your P.C, open your terminal and run the command pip --version or pip3 --version. If you get the pip version then it is safe to say that it has been installed.&lt;br&gt;
:~ $ pip --version&lt;br&gt;
pip 20.3.4 from/usr/lib/python3/dist-packages/pip (python 3.9)&lt;br&gt;
:~ $ pip3 --version&lt;br&gt;
pip 20.3.4 from/usr/lib/python3/dist-packages/pip (python 3.9)&lt;br&gt;
In any case you are not getting any result after executing the above command or you did manage to install pip run the command sudo apt install pip or sudo apt install pip3 on your terminal&lt;br&gt;
Installation of Django&lt;br&gt;
Django for Windows To install Django with PIP, open command prompt then go to Scripts directory where Python folder is and install Django by running the below command.&lt;br&gt;
C:\Python33\Scripts\pip.exe install django=="X.X"&lt;br&gt;
Django for Linux At the root level on your terminal execute the following codes.&lt;br&gt;
root: compgen -c | grep pip&lt;br&gt;
root: alias pip=pip-3.2&lt;br&gt;
: pip install django=="1.6"&lt;br&gt;
Django for Mac OS We install Django by running the command pip install django=="1.6" on the terminal.&lt;br&gt;
$ cd usr/local/bin&lt;br&gt;
ln -s ../../../Library/Frameworks/Python.framework/Version/3.3/bin/pip3&lt;br&gt;
pip&lt;br&gt;
$ pip install django=="1.6"&lt;br&gt;
Installing Virtual Environment(Virtualenv)&lt;br&gt;
We are creating a virtual environment to have a separate working environment for our new project. In order to install virtualenv, lets run pip or pip3 then using PIP we run pip install virtualenv. To check if virtualenv is installed the run the command virtualenv--version.&lt;br&gt;
:~ $ virtualenv--version&lt;br&gt;
virtualenv 20.10.0&lt;br&gt;
Creating Our First Project with Django&lt;br&gt;
• Before we start to use Django, lets create a folder/directory for this project on the Desktop by running the following command on the terminal.&lt;br&gt;
:~ $ pwd&lt;br&gt;
user/home/muks&lt;br&gt;
:~ $ ls&lt;br&gt;
Desktop Documents Downloads Pictures Music &lt;br&gt;
:~ $ cd Desktop/&lt;br&gt;
:~ Desktop $ mkdir demo_django&lt;br&gt;
:~ Desktop $ ls&lt;br&gt;
demo_django&lt;br&gt;
:~ Desktop $ cd demo_django&lt;br&gt;
~ Desktop/demo_django $&lt;br&gt;
• Under our new directory, lets create virtual environment by using the command virtualenv&lt;br&gt;
~ Desktop/demo_django $ virtualenv env&lt;br&gt;
• Make sure you activate the environment using source /bin/activate.&lt;br&gt;
:~ Desktop/demo_django $ source env/bin/activate&lt;br&gt;
• Inside our same created directory lets install Django by running pip install django.&lt;br&gt;
:~ Desktop/demo_django $ pip install django&lt;br&gt;
Collecting django&lt;br&gt;
• Lets begin our project by running the command django-admin startproject django_project1 which will create our project files on django_project1 and manage.py file.&lt;br&gt;
:~ Desktop/demo_django $ django-admin startproject django_project1&lt;br&gt;
:~ Desktop/demo_django $ ls django_project1 env manage.py&lt;br&gt;
• Now let make columns and tables in the database using the migration and migrate commands ./manage.py makemigrations and then ./manage.py migrate.&lt;/p&gt;

&lt;p&gt;[env] ~ Desktop/demo_django $ ./manage.py makemigrations&lt;br&gt;
• Consequently, as we are working on the project's main container directory on the manage.py file lets run ./manage.py runserver which runs on port 8000 by default but if we specify the port number it won't run on default e.g ./manage.py runserver 7000&lt;br&gt;
[env] :~ Desktop/demo_django $ ./manage.py runserver&lt;br&gt;
Performing system checks...&lt;/p&gt;

&lt;p&gt;System check identified no issues (0 silenced).&lt;br&gt;
May 1, 2022 - 10:51:11&lt;br&gt;
Django version 4.0.2, using settings 'django_project1.settings'&lt;br&gt;
Starting development server at &lt;a href="http://127.0.0.1:8000/" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/&lt;/a&gt;&lt;br&gt;
Quit the server with CONTROL-C.&lt;br&gt;
Next, visit &lt;a href="https://127.0.0.1:8000/" rel="noopener noreferrer"&gt;https://127.0.0.1:8000/&lt;/a&gt; which will display the page shown below.&lt;/p&gt;

&lt;p&gt;• On the terminal to create a superuser run Python3 manage.py createsuperuser or ./manage.py createsuperuser and fill in the name the user, give an email, and set a password. Now, running your server ./manage.py runserver it will allow you to access the Django admin panel for your project.&lt;/p&gt;

&lt;p&gt;[env]:~ Desktop/demo_django $./manage.py createsuperuser&lt;br&gt;&lt;br&gt;
Username : admin&lt;br&gt;
Email address: &lt;a href="mailto:admin.admin@email.com"&gt;admin.admin@email.com&lt;/a&gt;&lt;br&gt;
Password: &lt;br&gt;
Password (again): &lt;br&gt;
Superuser created successfully.&lt;br&gt;
• Now try visit &lt;a href="https://127.0.0.1:8000/admin" rel="noopener noreferrer"&gt;https://127.0.0.1:8000/admin&lt;/a&gt; to check if you can be able to log in on the login admin page.&lt;br&gt;
Login page for Admin Fill out your details on the page i.e., the username and password that we created earlier:&lt;/p&gt;

&lt;p&gt;Admin page: You can then view  and explore your admin panel&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Ultimate Python Tutorial For Beginners</title>
      <dc:creator>Mukumbuta</dc:creator>
      <pubDate>Sun, 24 Apr 2022 15:49:18 +0000</pubDate>
      <link>https://dev.to/mukumbuta/the-ultimate-python-tutorial-for-beginners-36dm</link>
      <guid>https://dev.to/mukumbuta/the-ultimate-python-tutorial-for-beginners-36dm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt; is a powerful, yet very simple, multi-purpose, high level programming language which is used in various aspect of technology. To cite but a few examples, Python is used in web developemnt, software development, and Data Science and Machine learning. This tutorial, which by the way,is beginner friendly, will  explain all the fundamental concepts of python [programming.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction to Python Programming language&lt;/strong&gt;&lt;br&gt;
Python is developed by Guido van Rossum. He named it Python after the comedy television show Monty Python’s Flying Circus. Guido van Rossum started implementing Python in 1989 and officially released in 1991.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features of Python programming language&lt;/strong&gt; &lt;br&gt;
&lt;strong&gt;Readability:&lt;/strong&gt; Python is a very readable language.&lt;br&gt;
&lt;strong&gt;Easy to Learn:&lt;/strong&gt; Learning python is easy as this is a expressive and high level programming language, which means it is easy to understand the language and thus easy to learn.&lt;br&gt;
&lt;strong&gt;Cross platform:&lt;/strong&gt; Python is available and can run on various operating systems such as Mac, Windows, Linux, Unix etc. This makes it a cross platform and portable language.&lt;br&gt;
&lt;strong&gt;Open Source:&lt;/strong&gt; Python is a open source programming language.&lt;br&gt;
&lt;strong&gt;Large standard library:&lt;/strong&gt; Python comes with a large standard library that has some handy codes and functions which we can use while writing code in Python.&lt;br&gt;
&lt;strong&gt;Free:&lt;/strong&gt; Python is free to download and use. This means you can download it for free and use it in your application. It is also open source which means you can freely distribute copies of this software, read its source code and modify it.&lt;br&gt;
&lt;strong&gt;Supports exception handling:&lt;/strong&gt; If you are new, you may wonder what is an exception? An exception is an event that can occur during program exception and can disrupt the normal flow of program. Python supports exception handling which means we can write less error prone code and can test various scenarios that can cause an exception later on.&lt;br&gt;
&lt;strong&gt;Advanced features:&lt;/strong&gt; Supports generators and list comprehensions. We will cover these features later.&lt;br&gt;
&lt;strong&gt;Automatic memory management:&lt;/strong&gt; Python supports automatic memory management which means the memory is cleared and freed automatically. You do not have to bother clearing the memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What we can do with Python&lt;/strong&gt;&lt;br&gt;
You may be wondering what all are the applications of Python. There are so many applications of Python, here are some of the them. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Web development&lt;/strong&gt; – Web framework like Django and Flask are based on Python. They help you write server side code which helps you manage database, write backend programming logic, mapping urls etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Machine learning&lt;/strong&gt; – There are many machine learning applications written in Python. Machine learning is a way to write a logic so that a machine can learn and solve a particular problem on its own. For example, products recommendation in websites like Amazon, Flipkart, eBay etc. is a machine learning algorithm that recognises user’s interest. Face recognition and Voice recognition in your phone is another example of machine learning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Analysis&lt;/strong&gt; – Data analysis and data visualisation in form of charts can also be developed using Python.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scripting&lt;/strong&gt; – Scripting is writing small programs to automate simple tasks such as sending automated response emails etc. Such type of applications can also be written in Python programming language.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Game development&lt;/strong&gt; – You can develop games using Python.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Development Embedded applications&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Desktop applications&lt;/strong&gt; – You can develop desktop application in Python using library like TKinter or QT.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;How to install Python&lt;/strong&gt;&lt;br&gt;
Python installation is pretty simple, you can install it on any operating system such as Windows, Mac OS X, Ubuntu etc. &lt;br&gt;
To install the Python on your operating system, go to this &lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;link:&lt;/a&gt; which is the official Python website and it will detect the operating system and based on that it would recommend you to download Python. Always rememeber to download the latest version of Python (Python 3.8 or higher).&lt;br&gt;
Installation steps are pretty simple. You just have to accept the agreement and finish the installation.&lt;br&gt;
It must be noted, however, that most operating systems come with Python already installed. To check if you have python installed, go toyour terminal and type:&lt;br&gt;
    &lt;em&gt;$ python --version&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Install an IDE *&lt;/em&gt;&lt;br&gt;
In order to run Python code, you will need an IDE. Popular once include: &lt;em&gt;VSCode&lt;/em&gt;, &lt;em&gt;PyCharm&lt;/em&gt;, &lt;em&gt;Atom&lt;/em&gt;, etc,. You can go ahead and install an IDE of your choice.&lt;br&gt;
For newbies, IDE stands for Integrated Development Environment. It is a software that consolidates the basic tools that are required to write and test programs in a given language. &lt;br&gt;
Typically, an IDE contains a code editor, a compiler or interpreter and a debugger. You can access all these at the same place through  the IDE GUI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comments in Python Programming&lt;/strong&gt;&lt;br&gt;
Comments are an essential part of, not just Python, but any programming language. Although they do not change the outcome of a program. &lt;br&gt;
A comment is text that doesn’t affect the outcome of a code, it is just a piece of text to let someone know what you have done in a program or what is being done in a block of code. This is especially helpful when someone else has written a code and you are analysing it for bug fixing or making a change in logic, by reading a comment you can understand the purpose of code much faster then by just going through the actual code.&lt;br&gt;
To write a comment in Python, simply use a hashtag before the comment as shown below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*# This is just a text, it won't be executed.*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;print("Python comment example")&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
    &lt;em&gt;Python comment example&lt;/em&gt;*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Comments in Python&lt;/strong&gt;&lt;br&gt;
There are two types of comments in Python. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Single line comment &lt;/li&gt;
&lt;li&gt;Multiple line comment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Single line comment&lt;/strong&gt;&lt;br&gt;
In python we use # special character to start the comment as in shown below:&lt;br&gt;
    &lt;em&gt;#This is just a comment. Anything written here is ignored by Python&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Multi-line comment:&lt;br&gt;
To have a multi-line comment in Python, we use triple single quotes at the beginning and at the end of the comment, as shown below.&lt;/p&gt;

&lt;p&gt;*'''&lt;br&gt;
This is a &lt;br&gt;
multi-line&lt;br&gt;
comment&lt;br&gt;
*'''&lt;/p&gt;

&lt;p&gt;Python Comments Example&lt;br&gt;
In this Python program we are seeing three types of comments. Single line comment, multi-line comment and the comment that is starting in the same line after the code.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*'''
We are writing a simple program here
First print statement.
This is a multiple line comment.
'''
print("Hello World!")

# Second print statement
print("I’m learning python programming")
print("Welcome to the world of coding.") # Third print statement*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Output:&lt;/em&gt;&lt;br&gt;
    &lt;em&gt;Hello World!&lt;br&gt;
    I’m learning python programming&lt;br&gt;
    Welcome to the world of coding.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; When # character is encountered inside quotes, it is not considered as comment. For example:&lt;br&gt;
    &lt;em&gt;print("#this is not a comment")&lt;br&gt;
**Output:&lt;/em&gt;*&lt;br&gt;
    &lt;em&gt;#this is not a comment&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Variables with examples&lt;/strong&gt;&lt;br&gt;
Variables are used to store data, they take memory space based on the type of value we assigning to them. Creating variables in Python is simple, you just have write the variable name on the left side of = and the value on the right side, as shown below. You do not have to explicitly mention the type of the variable, python infer the type based on the value we are assigning.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    *number = 100      #number is of type int
str = "Mukumbuta"      #str is of type string*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Identifiers in Python&lt;/strong&gt;&lt;br&gt;
There are some basic rules that one have to follow when naming variables (also known as Identifiers) in Python. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The name of the variable must always start with either a letter or an underscore (_). For example: _str, str, num, _num are all valid name for the variables. &lt;/li&gt;
&lt;li&gt;The name of the variable cannot start with a number. For example: 9num is not a valid variable name.&lt;/li&gt;
&lt;li&gt;The name of the variable cannot have special characters such as %, $, # etc, they can only have alphanumeric characters and underscore (A to Z, a to z, 0-9 or _ ).&lt;/li&gt;
&lt;li&gt;Variable name is case sensitive in Python. this means number  is different from NUM.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Python Variable Example&lt;/strong&gt;&lt;br&gt;
    &lt;em&gt;num = 100&lt;br&gt;
    str = "The Ultimate Guide"&lt;br&gt;
    print(num)&lt;br&gt;
    print(str)&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
    &lt;em&gt;100&lt;br&gt;
    The ultimate Guide&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can also assign multiple variables in a single statement in Python like so:&lt;br&gt;
    &lt;em&gt;x = y = z = 99&lt;br&gt;
    print(x)&lt;br&gt;
    print(y)&lt;br&gt;
    print(z)&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
    &lt;em&gt;99&lt;br&gt;
    99&lt;br&gt;
    99&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concatination in python&lt;/strong&gt;&lt;br&gt;
    *x = 10&lt;br&gt;
    y = 20&lt;br&gt;
    print(x + y)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p = "Hello"
q = "World"
print(p + " " + q)*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
    &lt;em&gt;30&lt;br&gt;
    Hellow World&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; If you attempt to use the + operator with variable x and p, the program will throw and error on your face that gose somethinglike:&lt;br&gt;
    &lt;strong&gt;&lt;em&gt;unsupported operand type(s) for +: 'int' and 'str'&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Types&lt;/strong&gt;&lt;br&gt;
A data type defines the type of data, for example 100 is an integer data while “Hello” is a String type of data. The data types in Python are divided in two categories: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Immutable data types – Values cannot be changed. &lt;/li&gt;
&lt;li&gt;Mutable data types – Values can be changedImmutable data types in Python are:

&lt;ol&gt;
&lt;li&gt;Strings&lt;/li&gt;
&lt;li&gt;Tuple&lt;/li&gt;
&lt;li&gt;Numbers
Mutable data types in Python are:&lt;/li&gt;
&lt;li&gt;Dictionaries&lt;/li&gt;
&lt;li&gt;Lists&lt;/li&gt;
&lt;li&gt;Sets&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Python Keywords and Identifiers with examples&lt;/strong&gt;&lt;br&gt;
In this article, we will discuss Keywords and Identifiers in Python with the help of examples.&lt;br&gt;
A python keyword is a reserved word which you can’t use as a name of your variable, class, function etc. These keywords have a special meaning and they are used for special purposes in Python programming language. For example – Python keyword &lt;em&gt;“while”&lt;/em&gt; is used for while loop thus you can’t name a variable with the name “while” else it may cause compilation error.&lt;br&gt;
To get the list of keywords on your system, open command prompt (terminal on Mac OS) and type trhe following:   &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    *$ Python 3.6
...
&amp;gt;&amp;gt;&amp;gt; help()
Welcome to Python 3.6's help utility!
...
help&amp;gt; keywords*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
*Here is a list of the Python keywords.  Enter any keyword to get more help.&lt;/p&gt;

&lt;p&gt;False               def                 if                     raise&lt;br&gt;
None               del                 import             return&lt;br&gt;
True                elif                 in                     try&lt;br&gt;
and                  else                is                      while&lt;br&gt;
as                    except            lambda              with&lt;br&gt;
assert              finally            nonlocal            yield&lt;br&gt;
break              for                  not&lt;br&gt;&lt;br&gt;
class               from               or&lt;br&gt;&lt;br&gt;
continue         global             pass*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Python keyword&lt;/strong&gt;&lt;br&gt;
In the following example we are using while keyword to create a loop for displaying the values of variables num as long as they are greater than 5.&lt;br&gt;
&lt;em&gt;num = 10&lt;br&gt;
while num&amp;gt;5:&lt;br&gt;
    print(num)&lt;br&gt;
    num -= 1&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
    &lt;em&gt;10&lt;br&gt;
    9&lt;br&gt;
    8&lt;br&gt;
    7&lt;br&gt;
    6&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Numeric Data Type in Python&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Integers&lt;/strong&gt;&lt;br&gt;
In Python 3, there is no upper bound on the integer number which means we can have the value as large as our system memory allows.&lt;br&gt;
&lt;em&gt;# Integer number&lt;br&gt;
num = 100&lt;br&gt;
print(num)&lt;br&gt;
print("Data Type of variable num is", type(num))&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Long Data Type&lt;/strong&gt; &lt;br&gt;
Long data type is deprecated in Python 3 because there is no need for it, since the integer has no upper limit, there is no point in having a data type that allows larger upper limit than integers.&lt;br&gt;
&lt;strong&gt;Float Data type&lt;/strong&gt;&lt;br&gt;
Values with decimal points are the float values, there is no need to specify the data type in Python. It is automatically inferred based on the value we are assigning to a variable. For example here fnum is a float data type.&lt;br&gt;
      &lt;em&gt;# float number&lt;br&gt;
      fnum = 34.45&lt;br&gt;
      print(fnum)&lt;br&gt;
      print("Data Type of variable fnum is", type(fnum))&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;34.45&lt;br&gt;
        Data Type of variable fnum is, float&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complex Numbers&lt;/strong&gt;&lt;br&gt;
Numbers with real and imaginary parts are known as complex numbers. Unlike other programming language such as Java, Python is able to identify these complex numbers with the values. In the following example when we print the type of the variable cnum, it prints as complex number.&lt;/p&gt;

&lt;h1&gt;
  
  
  complex number
&lt;/h1&gt;

&lt;p&gt;cnum = 3 + 4j&lt;br&gt;
print(cnum)&lt;br&gt;
print("Data Type of variable cnum is", type(cnum))&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Data Type – String&lt;/strong&gt;&lt;br&gt;
String is a sequence of characters in Python. The data type of String in Python is called &lt;em&gt;“str”&lt;/em&gt;.&lt;br&gt;
Strings in Python are either enclosed with single quotes or double quotes. &lt;br&gt;
       _# Python program to print strings and type&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   f_word = "First String"
   s_word = 'Second String'
   # displaying string s and its type
   print(f_word)
   print(type(f_word))

   # displaying string s_word and its type
   print(s_word)
   print(type(s_word))_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Data Type – Tuple&lt;/strong&gt;&lt;br&gt;
Tuple is immutable data type in Python which means it cannot be changed. It is an ordered collection of elements enclosed in round brackets and separated by commas.&lt;br&gt;
     _# tuple of integers&lt;br&gt;
     f_tuple = (1, 2, 3, 4, 5)&lt;br&gt;
     #prints entire tuple&lt;br&gt;
     print(f_tuple)&lt;br&gt;
     #tuple of strings&lt;br&gt;
     t2 = ("hi", "hello", "bye")&lt;br&gt;
     #loop through tuple elements&lt;br&gt;
     for s in t2:&lt;br&gt;
         print (s)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; #tuple of mixed type elements
 t3 = (2, "Lucy", 45, "Steve")
 '''
 Print a specific element
 indexes start with zero
 '''
 print(t3[2])_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Data Type – List&lt;/strong&gt;&lt;br&gt;
List is similar to tuple, it is also an ordered collection of elements, however list is a mutable data type which means it can be changed unlike tuple which is an immutable data type.&lt;br&gt;
A list is enclosed with square brackets and elements are separated by commas.&lt;br&gt;
      _# list of integers&lt;br&gt;
      f_list = [1, 2, 3, 4, 5]&lt;br&gt;
      #prints entire list&lt;br&gt;
      print(f_list)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; #list of strings
 s_list = ["Apple", "Orange", "Banana"]
 # loop through list elements
 for x in s_list:
     print (x)

 # List of mixed type elements
 c_list = [20, "Mukumbuta", 15, "The Ultimate Guide"]
 '''
 Print a specific element in list
 indexes start with zero
 '''
 print("Element at index 3 is:",c_list[3])_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Data Type – Dictionary&lt;/strong&gt;&lt;br&gt;
Dictionary is a collection of key and value pairs. A dictionary doesn’t allow duplicate keys but the values can be duplicate. It is an ordered, indexed and mutable collection of elements. &lt;br&gt;
The keys in a dictionary doesn’t necessarily to be a single data type, as you can see in the following example that we have 1 integer key and two string keys.&lt;br&gt;
     _# Dictionary example&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; dict = {1:"Mukumbuta","lastname":"Singh", "age":31}

 # prints the value where key value is 1
 print(dict[1])
 # prints the value where key value is "lastname"
 print(dict["lastname"])
 # prints the value where key value is "age"
 print(dict["age"])_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Data Type – Set&lt;/strong&gt;&lt;br&gt;
A set is an unordered and unindexed collection of items. This means when we print the elements of a set they will appear in the random order and we cannot access the elements of set based on indexes because it is unindexed.&lt;br&gt;
Elements of set are separated by commas and enclosed in curly braces.&lt;br&gt;
     *# Set Example&lt;br&gt;
     myset = {"hi", 2, "bye", "Hello World"}&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; # loop through set
 for a in myset:
     print(a)

 # checking whether 2 exists in myset
 print(2 in myset)

 # adding new element
 myset.add(99)
 print(myset)_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python conditionals&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;The If statement&lt;/strong&gt;&lt;br&gt;
If statements are control flow statements which helps us to run a particular code only when a certain condition is satisfied. For example, you want to print a message on the screen only when a condition is true then you can use if statement to accomplish this in programming. In this section, we will learn about the IF statement.&lt;br&gt;
There are other control flow statements available in Python such as *if..else, if..elif..else,&lt;br&gt;
nested if_ etc. However in this guide, we will only cover the if statements, other control statements are covered in separate tutorials.&lt;br&gt;
Syntax of If statement in Python&lt;br&gt;
The syntax of if statement in Python is pretty simple.&lt;br&gt;
&lt;em&gt;if condition:&lt;br&gt;
   block_of_code&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python – If statement Example&lt;/strong&gt;&lt;br&gt;
   &lt;em&gt;flag = True&lt;br&gt;
    if flag==True:&lt;br&gt;
       print("Welcome")&lt;br&gt;
       print("To")&lt;br&gt;
       print("TheUltimateGuide.com")&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        Welcome&lt;br&gt;
        To&lt;br&gt;
        TheUltimateGuide.com&lt;br&gt;
In the above example we are checking the value of flag variable and if the value is True then we are executing few print statements. The important point to note here is that even if we do not compare the value of flag with the ‘True’ and simply put ‘flag’ in place of condition, the code would run just fine so the better way to write the above code would be:&lt;br&gt;
     &lt;em&gt;flag = True&lt;br&gt;
      if flag:&lt;br&gt;
         print("Welcome")&lt;br&gt;
         print("To")&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now we understand better how &lt;em&gt;if&lt;/em&gt; statement works. The output of the condition would either be true or false. If the outcome of condition is true then the statements inside body of ‘if’ executes, however if the outcome of condition is false then the statements inside ‘if’ are skipped. Lets take another example to understand this:&lt;br&gt;
     &lt;em&gt;flag = False&lt;br&gt;
     if flag:&lt;br&gt;
        print("You Guys")&lt;br&gt;
        print("are")&lt;br&gt;
        print("Awesome")&lt;/em&gt;&lt;br&gt;
The output of this code is none, it does not print anything because the outcome of condition is ‘false’.&lt;br&gt;
Python if example without boolean variables&lt;br&gt;
In the above examples, we have used the boolean variables in place of conditions. However we can use any variables in our conditions. For example:&lt;br&gt;
      &lt;em&gt;num = 100&lt;br&gt;
      if num &amp;lt; 200:&lt;br&gt;
         print("num is less than 200")&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Output:**&lt;br&gt;
       _num is less than 200&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python If else Statement Example&lt;/strong&gt;&lt;br&gt;
In this guide, we will learn another control statement &lt;em&gt;‘if..else’&lt;/em&gt;.&lt;br&gt;
We use if statements when we need to execute a certain block of Python code when a particular condition is true. If..else statements are like extension of ‘if’ statements, with the help of if..else we can execute certain statements if condition is true and a different set of statements if condition is false. For example, you want to print ‘even number’ if the number is even and ‘odd number’ if the number is not even, we can accomplish this with the help of if..else statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
      if condition:&lt;br&gt;
          block_of_code_1print("TheUltimateGuide.com)&lt;br&gt;
      else:&lt;br&gt;
          block_of_code_2&lt;br&gt;
block_of_code_1: This would execute if the given condition is true &lt;br&gt;
block_of_code_2: This would execute if the given condition is false&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If-else example in Python&lt;/strong&gt;&lt;br&gt;
       &lt;em&gt;num = 22&lt;br&gt;
       if num % 2 == 0:&lt;br&gt;
           print("Even Number")&lt;br&gt;
       else:&lt;br&gt;
           print("Odd Number")&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;Even Number&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax of if elif else statement in Python&lt;/strong&gt;&lt;br&gt;
This way we are checking multiple conditions.&lt;br&gt;
&lt;em&gt;if condition:&lt;br&gt;
   block_of_code_1&lt;br&gt;
elif condition_2:&lt;br&gt;
   block_of_code_2&lt;br&gt;
elif condition_3:&lt;br&gt;
   block_of_code_3&lt;br&gt;
...&lt;br&gt;
...&lt;br&gt;
else:&lt;br&gt;
  block_of_code_n&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
In this example, we are checking multiple conditions using if..elif..else statement.&lt;br&gt;
        &lt;em&gt;num = 1122&lt;br&gt;
        if 9 &amp;lt; num &amp;lt; 99:&lt;br&gt;
            print("Two digit number")&lt;br&gt;
        elif 99 &amp;lt; num &amp;lt; 999:&lt;br&gt;
            print("Three digit number")&lt;br&gt;
        elif 999 &amp;lt; num &amp;lt; 9999:&lt;br&gt;
            print("Four digit number")&lt;br&gt;
        else:&lt;br&gt;
            print("number is &amp;lt;= 9 or &amp;gt;= 9999")&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Nested If else statement&lt;/strong&gt;&lt;br&gt;
In this part of the tutorial, we will learn the nesting of the control statements we covered above.&lt;br&gt;
When there an if statement (or if..else or if..elif..else) is present inside another if statement (or if..else or if..elif..else) then we call this nested control statements.&lt;br&gt;
Nested if..else statement example&lt;br&gt;
Here we have a if statement inside another if..else statement block. Nesting control statements makes us to check multiple conditions:&lt;br&gt;
       &lt;em&gt;num = -99&lt;br&gt;
       if num &amp;gt; 0:&lt;br&gt;
           print("Positive Number")&lt;br&gt;
       else:&lt;br&gt;
           print("Negative Number")&lt;br&gt;
       #nested if&lt;br&gt;
          if -99&amp;lt;=num:&lt;br&gt;
              print("Two digit Negative Number")&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
       &lt;em&gt;Negative Number&lt;br&gt;
        Two digit Negative Number&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python for Loop explained with examples&lt;/strong&gt;&lt;br&gt;
A loop is a used for iterating over a set of statements repeatedly. In Python we have three types of loops for, while and do-while. In this guide, we will learn for loop and the other two loops are covered in the separate tutorials.&lt;br&gt;
Syntax of For loop in Python&lt;br&gt;
&lt;em&gt;for  in :&lt;br&gt;&lt;br&gt;
   # body_of_loop that has set of statements&lt;br&gt;
   # which requires repeated execution&lt;/em&gt;&lt;br&gt;
Here &lt;em&gt;&lt;/em&gt; is a variable that is used for iterating over a &lt;em&gt;&lt;/em&gt;. On every iteration it takes the next value from &lt;em&gt;&lt;/em&gt; until the end of sequence is reached.&lt;br&gt;
Lets take few examples of for loop to understand the usage.&lt;br&gt;
Python – For loop example&lt;br&gt;
The following example shows the use of for loop to iterate over a list of numbers. In the body of for loop we are calculating the square of each number present in list and displaying the same.&lt;/p&gt;

&lt;h1&gt;
  
  
  Program to print squares of all numbers present in a list
&lt;/h1&gt;

&lt;h1&gt;
  
  
  List of integer numbers
&lt;/h1&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; _numbers = [1, 2, 4, 6, 11, 20]_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  variable to store the square of each num temporary
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; _sq = 0_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  iterating over the given list
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; _for val in numbers:_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  calculating square of each number
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_sq = val * val_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  displaying the squares
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_print(sq)_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;1&lt;br&gt;
         4&lt;br&gt;
         16&lt;br&gt;
         36&lt;br&gt;
         121&lt;br&gt;
         400&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function range()&lt;/strong&gt;&lt;br&gt;
In the above example, we have iterated over a list using for loop. However we can also use a &lt;em&gt;range()&lt;/em&gt; function in for loop to iterate over numbers defined by &lt;em&gt;range()&lt;/em&gt;.&lt;br&gt;
range(n): generates a set of whole numbers starting from 0 to (n-1). &lt;br&gt;
For example: range(8) is equivalent to [0, 1, 2, 3, 4, 5, 6, 7]&lt;br&gt;
range(start, stop): generates a set of whole numbers starting from start to stop-1. &lt;br&gt;
For example: range(5, 9) is equivalent to [5, 6, 7, 8]&lt;br&gt;
range(start, stop, step_size): The default step_size is 1 which is why when we didn’t specify the step_size, the numbers generated are having difference of 1. However by specifying step_size we can generate numbers having the difference of step_size. &lt;br&gt;
For example: range(1, 10, 2) is equivalent to [1, 3, 5, 7, 9]&lt;br&gt;
Lets use the range() function in for loop:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python for loop example using range() function&lt;/strong&gt;&lt;br&gt;
Here we are using range() function to calculate and display the sum of first 5 natural numbers.&lt;/p&gt;

&lt;h1&gt;
  
  
  Program to print the sum of first 5 natural numbers
&lt;/h1&gt;

&lt;h1&gt;
  
  
  variable to store the sum
&lt;/h1&gt;

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

&lt;/div&gt;
&lt;h1&gt;
  
  
  iterating over natural numbers using range()
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  for val in range(1, 6):
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  calculating sum
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       sum = sum + val
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  displaying sum of first 5 natural numbers
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       print(sum)_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
15&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For loop with else block&lt;/strong&gt;&lt;br&gt;
In Python we can have an optional ‘else’ block associated with the loop. The ‘else’ block executes only when the loop has completed all the iterations. Lets take an example:&lt;br&gt;
         &lt;em&gt;for val in range(5):&lt;br&gt;
          print(val)&lt;br&gt;
          else:&lt;br&gt;
          print("The loop has completed execution")&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;0&lt;br&gt;
         1&lt;br&gt;
         2&lt;br&gt;
         3&lt;br&gt;
         4&lt;/em&gt;&lt;br&gt;
The loop has completed execution&lt;br&gt;
Note: The else block only executes when the loop is finished.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nested For loop in Python&lt;/strong&gt;&lt;br&gt;
When a for loop is present inside another for loop then it is called a nested for loop. Lets take an example of nested for loop.&lt;br&gt;
        &lt;em&gt;for num1 in range(3):&lt;br&gt;
          for num2 in range(10, 14):&lt;br&gt;
          print(num1, ",", num2)&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;0 , 10&lt;br&gt;
         0 , 11&lt;br&gt;
         0 , 12&lt;br&gt;
         ...&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Python While Loop&lt;/strong&gt;&lt;br&gt;
While loop is used to iterate over a block of code repeatedly until a given condition returns false. The main difference between a for loop and a while loop is that we use while loop when we are not certain of the number of times the loop requires execution, on the other hand when we exactly know how many times we need to run the loop, we use for loop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax of while loop&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;while condition:&lt;br&gt;
    #body_of_while&lt;/em&gt;&lt;br&gt;
The body_of_while is set of Python statements which requires repeated execution. These set of statements execute repeatedly until the given condition returns false.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flow of while loop&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First the given condition is checked, if the condition returns false, the loop is terminated and the control jumps to the next statement in the program after the loop.&lt;/li&gt;
&lt;li&gt;If the condition returns true, the set of statements inside loop are executed and then the control jumps to the beginning of the loop for next iteration.
These two steps happen repeatedly as long as the condition specified in while loop remains true.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Python – While loop example&lt;/strong&gt;&lt;br&gt;
Here is an example of while loop. In this example, we have a variable num and we are displaying the value of num in a loop, the loop has a increment operation where we are increasing the value of num. This is very important step, the while loop must have a increment or decrement operation, else the loop will run indefinitely, we will cover this later in infinite while loop.&lt;br&gt;
         num = 1&lt;br&gt;
         # loop will repeat itself as long as&lt;br&gt;
         # num &amp;lt; 10 remains true&lt;br&gt;
         while num &amp;lt; 10:&lt;br&gt;
              print(num)&lt;br&gt;
         #incrementing the value of num&lt;br&gt;
              num = num + 3&lt;br&gt;
Output:&lt;br&gt;
      &lt;em&gt;1&lt;br&gt;
       4&lt;br&gt;
       7&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python – while loop with else block&lt;/strong&gt;&lt;br&gt;
We can have a ‘else’ block associated with while loop. The ‘else’ block is optional. It executes only after the loop finished execution.&lt;br&gt;
           &lt;em&gt;num = 10&lt;br&gt;
           while num &amp;gt; 6:&lt;br&gt;
                print(num)&lt;br&gt;
                num = num-1&lt;/em&gt;&lt;br&gt;
           else:&lt;br&gt;
                print("loop is finished")_&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
         &lt;em&gt;10&lt;br&gt;
          9&lt;br&gt;
          8&lt;br&gt;
          7&lt;/em&gt;&lt;br&gt;
loop is finished&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Functions&lt;/strong&gt;&lt;br&gt;
In this guide, we will learn about functions in Python. A function is a block of code that contains one or more Python statements and used for performing a specific task.&lt;br&gt;
&lt;strong&gt;Why use function in Python?&lt;/strong&gt;&lt;br&gt;
Like we've already established, a function is a block of code that performs a specific task. Lets discuss what we can achieve in Python by using functions in our code: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Code re-usability:&lt;/strong&gt; Lets say we are writing an application in Python where we need to perform a specific task in several places of our code, assume that we need to write 10 lines of code to do that specific task. It would be better to write those 10 lines of code in a function and just call the function wherever needed, because writing those 10 lines every time you perform that task is tedious, it would make your code lengthy, less-readable and increase the chances of human errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improves Readability:&lt;/strong&gt; By using functions for frequent tasks you make your code structured and readable. It would be easier for anyone to look at the code and be able to understand the flow and purpose of the code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid redundancy:&lt;/strong&gt; When you no longer repeat the same lines of code throughout the code and use functions in places of those, you actually avoiding the redundancy that you may have created by not using functions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Syntax of functions in Python&lt;/strong&gt;&lt;br&gt;
Function declaration:&lt;br&gt;
def function_name(function_parameters):&lt;br&gt;
    function_body # Set of Python statements&lt;br&gt;
        return # optional return statement&lt;/p&gt;

&lt;p&gt;Calling the function:&lt;/p&gt;

&lt;h1&gt;
  
  
  when function doesn't return anything
&lt;/h1&gt;

&lt;p&gt;function_name(parameters)&lt;br&gt;
OR&lt;/p&gt;

&lt;h1&gt;
  
  
  when function returns something
&lt;/h1&gt;

&lt;h1&gt;
  
  
  variable is to store the returned value
&lt;/h1&gt;

&lt;p&gt;variable = function_name(parameters)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Function example&lt;/strong&gt;&lt;br&gt;
Here we have a function &lt;em&gt;add()&lt;/em&gt; that adds two numbers passed to it as parameters. Later after function declaration we are calling the function twice in our program to perform the addition.&lt;br&gt;
       _def add(num1, num2):&lt;br&gt;
            return num1 + num2&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   sum1 = add(100, 200)
   sum2 = add(8, 9)
   print(sum1)
   print(sum2)_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
         &lt;em&gt;300&lt;br&gt;
          17&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default arguments in Function&lt;/strong&gt;&lt;br&gt;
Now that we know how to declare and call a function, lets see how can we use the default arguments. By using default arguments we can avoid the errors that may arise while calling a function without passing all the parameters. Lets take an example to understand this:&lt;br&gt;
In this example we have provided the default argument for the second parameter, this default argument would be used when we do not provide the second parameter while calling this function.&lt;br&gt;
*# default argument for second parameter&lt;br&gt;
def add(num1, num2=1):&lt;br&gt;
    return num1 + num2&lt;/p&gt;

&lt;p&gt;sum1 = add(100, 200)&lt;br&gt;
sum2 = add(8)  # used default argument for second param&lt;br&gt;
sum3 = add(100)  # used default argument for second param&lt;br&gt;
print(sum1)&lt;br&gt;
print(sum2)&lt;br&gt;
print(sum3)*&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;300&lt;br&gt;
9&lt;br&gt;
101&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of functions&lt;/strong&gt;&lt;br&gt;
There are two types of functions in Python: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Built-in functions: These functions are predefined in Python and we need not to declare these functions before calling them. We can freely invoke them as and when needed.&lt;/li&gt;
&lt;li&gt;User defined functions: The functions which we create in our code are user-defined functions. The add() function that we have created in above examples is a user-defined function.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Python Numbers&lt;/strong&gt;&lt;br&gt;
In this guide, we will see how to work with numbers in Python. Python supports integers, floats and complex numbers.&lt;br&gt;
An integer is a number without decimal point for example 5, 6, 10 etc.&lt;br&gt;
A float is a number with decimal point for example 6.7, 6.0, 10.99 etc.&lt;br&gt;
A complex number has a real and imaginary part for example 7+8j, 8+11j etc.&lt;br&gt;
Example: Numbers in Python&lt;/p&gt;

&lt;h1&gt;
  
  
  Python program to display numbers of
&lt;/h1&gt;

&lt;h1&gt;
  
  
  different data types
&lt;/h1&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       *# int
       num1 = 10
       num2 = 100
       print(num1+num2)

       # float
       a = 10.5
       b = 8.9
       print(a-b)

       # complex numbers
       x = 3 + 4j
       y = 9 + 8j8
       print(y-x)*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;110&lt;br&gt;
         1.5999999999999996&lt;br&gt;
         (6+4j)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python List with examples&lt;/strong&gt;&lt;br&gt;
In this guide, we will discuss lists in Python. A list is a data type that allows you to store various types data in it. List is a compound data type which means you can have different-2 data types under a list, for example we can have integer, float and string items in a same list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create a List in Python&lt;/strong&gt;&lt;br&gt;
Lets see how to create a list in Python. To create a list all you have to do is to place the items inside a square bracket [] separated by comma,.&lt;br&gt;
     &lt;em&gt;#list of floats&lt;br&gt;
     num_list = [11.22, 9.9, 78.34, 12.0]&lt;br&gt;
     # list of int, float and strings&lt;br&gt;
     mix_list = [1.13, 2, 5, "TheUltimateGuide", 100, "hi"]&lt;br&gt;
     # an empty list&lt;br&gt;
     nodata_list = []&lt;/em&gt;&lt;br&gt;
As we have seen above, a list can have data items of same type or different types. This is the reason list comes under compound data type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax to access the list items:&lt;/strong&gt;&lt;br&gt;
          &lt;em&gt;list_name[index]&lt;/em&gt;&lt;br&gt;
Example:&lt;br&gt;
       *# a list of numbers&lt;br&gt;
        numbers = [11, 22, 33, 100, 200, 300]&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # prints 11
    print(numbers[0])

    # prints 300
    print(numbers[5])

    # prints 22
    print(numbers[1])*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
         &lt;em&gt;11&lt;br&gt;
          300&lt;br&gt;
          22&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Strings&lt;/strong&gt;&lt;br&gt;
A string is usually a bit of text (sequence of characters). In Python we use ” (double quotes) or ‘ (single quotes) to represent a string. In this guide we will see how to create, access, use and manipulate strings in Python programming language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to create a String in Python&lt;/strong&gt;&lt;br&gt;
There are several ways to create strings in Python. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We can use ‘ (single quotes), see the string str in the following code.&lt;/li&gt;
&lt;li&gt;We can use ” (double quotes), see the string str2 in the source code below.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Triple double quotes “”” and triple single quotes ”’ are used for creating multi-line strings in Python. See the strings str3 and str4 in the following example.&lt;/p&gt;
&lt;h1&gt;
  
  
  lets see the ways to create strings in Python
&lt;/h1&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;str = 'TheUltimateGuide'
print(str)

str2 = "Mukumbuta"
print(str2)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  multi-line string
&lt;/h1&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    str3 = """Welcome to 
              TheUltimateGuide.com
           """
    print(str3)

    str4 = '''This is a tech 
              blog
           '''
    print(str4)*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
         *TheUltimateGuide&lt;/p&gt;

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

      Welcome to 
      TheUltimateGuide.com

      This is a tech 
      blog*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to access strings in Python&lt;/strong&gt;&lt;br&gt;
A string is nothing but an array of characters so we can use the indexes to access the characters of a it. Just like arrays, the indexes start from 0 to the length-1.&lt;br&gt;
You will get IndexError if you try to access the character which is not in the range. For example,&lt;br&gt;
if a string is of length 6 and you try to access the 8th char of it then you will get this error.&lt;br&gt;
You will get TypeError if you do not use integers as indexes, for example if you use a float as an index then you will get this error.&lt;br&gt;
*str = "Timothy"&lt;/p&gt;

&lt;h1&gt;
  
  
  displaying whole string
&lt;/h1&gt;

&lt;p&gt;print(str)&lt;/p&gt;

&lt;h1&gt;
  
  
  displaying first character of string
&lt;/h1&gt;

&lt;p&gt;print(str[0])&lt;/p&gt;

&lt;h1&gt;
  
  
  displaying third character of string
&lt;/h1&gt;

&lt;p&gt;print(str[2])&lt;/p&gt;

&lt;h1&gt;
  
  
  displaying the last character of the string
&lt;/h1&gt;

&lt;p&gt;print(str[-1])*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python String Operations&lt;/strong&gt;&lt;br&gt;
Lets see the operations that can be performed on the strings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concatenation of strings in Python&lt;/strong&gt;&lt;br&gt;
The + operator is used for string concatenation in Python. Lets take an example to understand this:&lt;br&gt;
        *str1 = "One"&lt;br&gt;
        str2 = "Two"&lt;br&gt;
        str3 = "Three"&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Concatenation of three strings
    print(str1 + str2 + str3)*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;OneTwoThree&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Membership Operators in Strings&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;in:&lt;/strong&gt; This checks whether a string is present in another string or not. It returns true if the entire string is found else it returns false. &lt;br&gt;
&lt;strong&gt;not in:&lt;/strong&gt; It works just opposite to what “in” operator does. It returns true if the string is not found in the specified string else it returns false.&lt;br&gt;
            *str = "Welcome to TheUltimateGuide.com"&lt;br&gt;
            str2 = "Welcome"&lt;br&gt;
            str3 = "Mukumbuta"&lt;br&gt;
            str4 = "XYZ"&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        # str2 is in str? True
        print(str2 in str)

        # str3 is in str? False
        print(str3 in str)*

        # str4 not in str? True
        print(str4 not in str)*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;True&lt;br&gt;
         False&lt;br&gt;
         True&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Tuple with example&lt;/strong&gt;&lt;br&gt;
In Python, a tuple is similar to Lists except that the objects in tuple are immutable which means we cannot change the elements of a tuple once assigned. On the other hand, we can change the elements of a list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to create a tuple in Python&lt;/strong&gt;&lt;br&gt;
To create a tuple in Python, place all the elements in a () parenthesis, separated by commas. A tuple can have heterogeneous data items, a tuple can have string and list as data items as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example – Creating tuple&lt;/strong&gt;&lt;br&gt;
In this example, we are creating few tuples. We can have tuple of same type of data items as well as mixed type of data items. This example also shows nested tuple (tuples as data items in another tuple).&lt;br&gt;
       *# tuple of strings&lt;br&gt;
        my_data = ("hi", "hello", "bye")&lt;br&gt;
        print(my_data)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # tuple of int, float, string
    my_data2 = (1, 2.8, "Hello World")
    print(my_data2)

    # tuple of string and list
    my_data3 = ("Book", [1, 2, 3])
    print(my_data3)

    # tuples inside another tuple
    # nested tuple
    my_data4 = ((2, 3, 4), (1, 2, "hi"))
    print(my_data4)*  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;('hi', 'hello', 'bye')&lt;br&gt;
         (1, 2.8, 'Hello World')&lt;br&gt;
         ('Book', [1, 2, 3])&lt;br&gt;
         ((2, 3, 4), (1, 2, 'hi'))&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Empty tuple:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;# empty tuple&lt;br&gt;
my_data = ()&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tuple with only single element:&lt;/strong&gt;&lt;br&gt;
Note: When a tuple has only one element, we must put a comma after the element, otherwise Python will not treat it as a tuple.&lt;/p&gt;

&lt;h1&gt;
  
  
  a tuple with single data item
&lt;/h1&gt;

&lt;p&gt;my_data = (99,)&lt;br&gt;
If we do not put comma after 99 in the above example then python will treat my_data as an int variable rather than a tuple.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to access tuple elements&lt;/strong&gt;&lt;br&gt;
We use indexes to access the elements of a tuple. Lets take few example to understand the working.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessing tuple elements using positive indexes&lt;/strong&gt;&lt;br&gt;
We can also have negative indexes in tuple, we have discussed that in the next section. Indexes starts with 0 that is why we use 0 to access the first element of tuple, 1 to access second element and so on.&lt;br&gt;
       *# tuple of strings&lt;br&gt;
        my_data = ("hi", "hello", "bye")&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # displaying all elements
    print(my_data)

    # accessing first element
    # prints "hi"
    print(my_data[0])

    # accessing third element
    # prints "bye"
    print(my_data[2])*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;('hi', 'hello', 'bye')&lt;br&gt;
         hi&lt;br&gt;
         bye&lt;/em&gt;&lt;br&gt;
Note:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;TypeError: If you do not use integer indexes in the tuple. For example my_data[2.0] will raise this error. The index must always be an integer. &lt;/li&gt;
&lt;li&gt;IndexError: Index out of range. This error occurs when we mention the index which is not in the range. For example, if a tuple has 5 elements and we try to access the 7th element then this error would occurr.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Python Dictionary with examples&lt;/strong&gt;&lt;br&gt;
Dictionary is a mutable data type in Python. A python dictionary is a collection of key and value pairs separated by a colon (:), enclosed in curly braces {}.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Dictionary&lt;/strong&gt;&lt;br&gt;
Here we have a dictionary. Left side of the colon(:) is the key and right side of the : is the value.&lt;br&gt;
mydict = {'StuName': 'Peter', 'StuAge': 30, 'StuCity': 'Agra'}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessing dictionary values using keys in Python&lt;/strong&gt;&lt;br&gt;
To access a value we can can use the corresponding key in the square brackets as shown in the following example. Dictionary name followed by square brackets and in the brackets we specify the key for which we want the value.&lt;br&gt;
mydict = {'StuName': 'Ajeet', 'StuAge': 30, 'StuCity': 'Agra'}&lt;br&gt;
print("Student Age is:", mydict['StuAge'])&lt;br&gt;
print("Student City is:", mydict['StuCity'])&lt;br&gt;
Output:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Loop through a dictionary&lt;/strong&gt;&lt;br&gt;
We can loop through a dictionary as shown in the following example. Here we are using for loop.&lt;br&gt;
&lt;em&gt;mydict = {'StuName': 'Steve', 'StuAge': 4, 'StuCity': 'Agra'}&lt;br&gt;
for e in mydict:&lt;br&gt;
  print("Key:",e,"Value:",mydict[e])&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python OOPs Concepts&lt;/strong&gt;&lt;br&gt;
Python is an object-oriented programming language. What this means is we can solve a problem in Python by creating objects in our programs. In this guide, we will discuss OOPs terms such as class, objects, methods etc. along with the Object oriented programming features such as inheritance, polymorphism, abstraction, encapsulation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Objects in Python&lt;/strong&gt;&lt;br&gt;
An object is an entity that has attributes and behaviour. For example, Ram is an object who has attributes such as height, weight, color etc. and has certain behaviours such as walking, talking, eating etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Classes in Python&lt;/strong&gt;&lt;br&gt;
A class is a blueprint for the objects. For example, Ram, Shyam, Steve, Rick are all objects so we can define a template (blueprint) class Human for these objects. The class can define the common attributes and behaviours of all the objects.&lt;br&gt;
&lt;strong&gt;Methods&lt;/strong&gt;&lt;br&gt;
As we discussed above, an object has attributes and behaviours. These behaviours are called methods in programming.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Class and Objects&lt;/strong&gt;&lt;br&gt;
In this example, we have two objects; Ram and Steve that belong to the class Human &lt;br&gt;
Object attributes: name, height, weight &lt;br&gt;
Object behaviour: eating()&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;br&gt;
*class Human:&lt;br&gt;
    # instance attributes&lt;br&gt;
    def &lt;strong&gt;init&lt;/strong&gt;(self, name, height, weight):&lt;br&gt;
        self.name = name&lt;br&gt;
        self.height = height&lt;br&gt;
        self.weight = weight&lt;br&gt;
    # instance methods (behaviours)&lt;br&gt;
    def eating(self, food):&lt;br&gt;
        return "{} is eating {}".format(self.name, food)&lt;/p&gt;

&lt;h1&gt;
  
  
  creating objects of class Human
&lt;/h1&gt;

&lt;p&gt;ram = Human("Ram", 6, 60)&lt;br&gt;
steve = Human("Steve", 5.9, 56)&lt;/p&gt;

&lt;h1&gt;
  
  
  accessing object information
&lt;/h1&gt;

&lt;p&gt;print("Height of {} is {}".format(ram.name, ram.height))&lt;br&gt;
print("Weight of {} is {}".format(ram.name, ram.weight))&lt;br&gt;
print(ram.eating("Pizza"))&lt;br&gt;
print("Weight of {} is {}".format(steve.name, steve.height))&lt;br&gt;
print("Weight of {} is {}".format(steve.name, steve.weight))&lt;br&gt;
print(steve.eating("Big Kahuna Burger"))*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;Height of Ram is 6&lt;br&gt;
         Weight of Ram is 60&lt;br&gt;
         Ram is eating Pizza&lt;br&gt;
         Weight of Steve is 5.9&lt;br&gt;
         Weight of Steve is 56&lt;br&gt;
         Steve is eating Big Kahuna Burger&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to create Class and Objects in Python&lt;/strong&gt;&lt;br&gt;
In this tutorial, we will see how to create classes and objects in Python.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class definition in Python&lt;/strong&gt;&lt;br&gt;
A class is defined using the keyword class.&lt;br&gt;
Example&lt;br&gt;
In this example, we are creating an empty class DemoClass. This class has no attributes and methods.&lt;br&gt;
The string that we mention in the triple quotes is a docstring which is an optional string that briefly explains the purpose of the class.&lt;br&gt;
*class DemoClass:&lt;br&gt;
    """This is my docstring, this explains brief about the class"""&lt;/p&gt;

&lt;h1&gt;
  
  
  this prints the docstring of the class
&lt;/h1&gt;

&lt;p&gt;print(DemoClass.&lt;strong&gt;doc&lt;/strong&gt;)*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
       &lt;em&gt;This is my docstring, this explains brief about the class&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Objects of class&lt;/strong&gt;&lt;br&gt;
In this example, we have a class MyNewClass that has an attribute num and a function hello(). We are creating an object obj of the class and accessing the attribute value of object and calling the method hello() using the object.&lt;br&gt;
*class MyNewClass:&lt;br&gt;
    """This class demonstrates the creation of objects"""&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# instance attribute&lt;br&gt;
num = 100
&lt;h1&gt;
  
  
  instance method
&lt;/h1&gt;

&lt;p&gt;def hello(self):&lt;br&gt;
    print("Hello World!")&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  creating object of MyNewClass&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;obj = MyNewClass()&lt;/p&gt;

&lt;h1&gt;
  
  
  prints attribute value
&lt;/h1&gt;

&lt;p&gt;print(obj.num)&lt;/p&gt;

&lt;h1&gt;
  
  
  calling method hello()
&lt;/h1&gt;

&lt;p&gt;obj.hello()&lt;/p&gt;

&lt;h1&gt;
  
  
  prints docstring
&lt;/h1&gt;

&lt;p&gt;print(MyNewClass.&lt;strong&gt;doc&lt;/strong&gt;)*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;100&lt;br&gt;
         Hello World!&lt;br&gt;
         This class demonstrates the creation of objects&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Constructors – default and parameterized&lt;/strong&gt;&lt;br&gt;
A constructor is a special kind of method which is used for initializing the instance variables during object creation. In this guide, we will see what is a constructor, types of it and how to use them in the python programming with examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructors in Python&lt;/strong&gt;&lt;br&gt;
Constructor is used for initializing the instance members when we create the object of a class.&lt;br&gt;
For example: We have an instance variable num which we are initializing in the constructor. The constructor is being invoked when we create the object of the class (obj in the following example).&lt;br&gt;
*class DemoClass:&lt;br&gt;
    # constructor&lt;br&gt;
    def &lt;strong&gt;init&lt;/strong&gt;(self):&lt;br&gt;
        # initializing instance variable&lt;br&gt;
        self.num=100&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# a method&lt;br&gt;
def read_number(self):&lt;br&gt;
    print(self.num)&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  creating object of the class. This invokes constructor&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;obj = DemoClass()&lt;/p&gt;

&lt;h1&gt;
  
  
  calling the instance method using the object obj
&lt;/h1&gt;

&lt;p&gt;obj.read_number()*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;100&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax of constructor declaration&lt;/strong&gt;&lt;br&gt;
As we have seen in the above example that a constructor always has a name init and the name init is prefixed and suffixed with a double underscore(&lt;strong&gt;). We declare a constructor using def keyword, just like methods.&lt;br&gt;
_def __init&lt;/strong&gt;(self):&lt;br&gt;
    # body of the constructor_&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of constructors in Python&lt;/strong&gt;&lt;br&gt;
We have two types of constructors in Python. &lt;br&gt;
    1. Default constructor – this is the one, which we have seen in the above example. This constructor doesn’t accept any arguments&lt;br&gt;
    2. Parameterized constructor – constructor with parameters is known as parameterized constructor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python – default constructor example&lt;/strong&gt;&lt;br&gt;
Note: An object cannot be created if we don’t have a constructor in our program. This is why when we do not declare a constructor in our program, python does it for us. Lets have a look at the example below.&lt;/p&gt;

&lt;p&gt;Example: When we do not declare a constructor&lt;br&gt;
In this example, we do not have a constructor but still we are able to create an object for the class. This is because there is a default constructor implicitly injected by python during program compilation, this is an empty default constructor that looks like this:&lt;br&gt;
*def &lt;strong&gt;init&lt;/strong&gt;(self):&lt;br&gt;
    # no body, does nothing.&lt;/p&gt;

&lt;p&gt;Code:&lt;br&gt;
class DemoClass:&lt;br&gt;
    num = 101&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# a method&lt;br&gt;
def read_number(self):&lt;br&gt;
    print(self.num)&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  creating object of the class&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;obj = DemoClass()&lt;/p&gt;

&lt;h1&gt;
  
  
  calling the instance method using the object obj
&lt;/h1&gt;

&lt;p&gt;obj.read_number()*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;101&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Declaring a constructor example&lt;/strong&gt; &lt;br&gt;
In this case, python does not create a constructor in our program.&lt;br&gt;
*class DemoClass:&lt;br&gt;
    num = 101&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# non-parameterized constructor&lt;br&gt;
def &lt;strong&gt;init&lt;/strong&gt;(self):&lt;br&gt;
    self.num = 999
&lt;h1&gt;
  
  
  a method
&lt;/h1&gt;

&lt;p&gt;def read_number(self):&lt;br&gt;
    print(self.num)&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  creating object of the class&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;obj = DemoClass()&lt;/p&gt;

&lt;h1&gt;
  
  
  calling the instance method using the object obj
&lt;/h1&gt;

&lt;p&gt;obj.read_number()*&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;999&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python – Parameterized constructor example&lt;/strong&gt;&lt;br&gt;
When we declare a constructor in such a way that it accepts the arguments during object creation then such type of constructors are known as Parameterized constructors. As you can see that with such type of constructors we can pass the values (data) during object creation, which is used by the constructor to initialize the instance members of that object.&lt;br&gt;
*class DemoClass:&lt;br&gt;
    num = 101&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# parameterized constructor&lt;br&gt;
def &lt;strong&gt;init&lt;/strong&gt;(self, data):&lt;br&gt;
    self.num = data
&lt;h1&gt;
  
  
  a method
&lt;/h1&gt;

&lt;p&gt;def read_number(self):&lt;br&gt;
    print(self.num)&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  creating object of the class&lt;br&gt;
&lt;/h1&gt;

&lt;h1&gt;
  
  
  this will invoke parameterized constructor
&lt;/h1&gt;

&lt;p&gt;obj = DemoClass(55)&lt;/p&gt;

&lt;h1&gt;
  
  
  calling the instance method using the object obj
&lt;/h1&gt;

&lt;p&gt;obj.read_number()&lt;/p&gt;

&lt;h1&gt;
  
  
  creating another object of the class
&lt;/h1&gt;

&lt;p&gt;obj2 = DemoClass(66)&lt;/p&gt;

&lt;h1&gt;
  
  
  calling the instance method using the object obj
&lt;/h1&gt;

&lt;p&gt;obj2.read_number()*&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
        &lt;em&gt;55&lt;br&gt;
         66&lt;/em&gt;&lt;br&gt;
With that, we've covered most of the basics to get us started programming in Python. What now...?! Simple.&lt;br&gt;
Learn... Practice... Repeat... &lt;br&gt;
OK, that looks like an infinite loop.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Introduction to Scikit-Learn</title>
      <dc:creator>Mukumbuta</dc:creator>
      <pubDate>Wed, 06 Apr 2022 22:31:30 +0000</pubDate>
      <link>https://dev.to/mukumbuta/introduction-to-scikit-learn-3eji</link>
      <guid>https://dev.to/mukumbuta/introduction-to-scikit-learn-3eji</guid>
      <description>&lt;p&gt;In this article, we will be discussing Scikit learn. Scikit is an open-source Python library which provides a range of supervised and unsupervised machine learning algorithms. Besides this, Scikit also contains very powerful packages which include:&lt;br&gt;
 NumPy&lt;br&gt;
 Matplotlib&lt;br&gt;
 SciPy &lt;br&gt;
The above packages must be installed (using the Terminal) and imported in order to implement Scikit learn. In the same way, we need to import Scikit. Scikit is built upon SciPy (Science Python) which, also, must be installed.&lt;br&gt;
To install SciPy, type the command below in the Terminal:&lt;br&gt;
&lt;em&gt;Pip install scipy&lt;/em&gt;&lt;br&gt;
Scikit-learn comes from sample datasets, such as &lt;em&gt;iris&lt;/em&gt; and &lt;em&gt;digits&lt;/em&gt;. To use the afore mentioned, we need to import SVM (Support Vector Machine). SVM is a form of machine learning which is used to analyze data.&lt;br&gt;
We can take digits dataset and it will categorize the numbers for us. Let’s consider the code below:&lt;/p&gt;

&lt;p&gt;_import matplotlib.pyplot as plt&lt;br&gt;
from sklearn import datasets&lt;br&gt;
from sklearn import svm&lt;/p&gt;

&lt;p&gt;digits= datasets.load_digits()&lt;br&gt;
print(digits.data)_&lt;/p&gt;

&lt;p&gt;The Output of the above code will be:&lt;br&gt;
&lt;em&gt;[[ 0. 0. 5. ..., 0. 0. 0.]&lt;br&gt;
 [ 0. 0. 0. ..., 10. 0. 0.]&lt;br&gt;
 [ 0. 0. 0. ..., 16. 9. 0.]&lt;br&gt;
 ..., &lt;br&gt;
 [ 0. 0. 1. ..., 6. 0. 0.]&lt;br&gt;
 [ 0. 0. 2. ..., 12. 0. 0.]&lt;br&gt;
 [ 0. 0. 10. ..., 12. 1. 0.]]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The imported libraries above gives us access to the features that can be used to classify digits sample. The same can be done with images. Let’s consider the following line of code:&lt;/p&gt;

&lt;p&gt;_import matplotlib.pyplot as plt&lt;br&gt;
from sklearn import datasets&lt;br&gt;
from sklearn import svm&lt;/p&gt;

&lt;p&gt;digits= datasets.load_digits()&lt;br&gt;
print(digits.target)&lt;br&gt;
print(digits.images[0])_&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;[0 1 2 ..., 8 9 8]                  // target of the data&lt;br&gt;
[[ 0. 0. 5. 13. 9. 1. 0. 0.]         // image of the data&lt;br&gt;
 [ 0. 0. 13. 15. 10. 15. 5. 0.]&lt;br&gt;
 [ 0. 3. 15. 2. 0. 11. 8. 0.]&lt;br&gt;
 [ 0. 4. 12. 0. 0. 8. 8. 0.]&lt;br&gt;
 [ 0. 5. 8. 0. 0. 9. 8. 0.]&lt;br&gt;
 [ 0. 4. 11. 0. 1. 12. 7. 0.]&lt;br&gt;
 [ 0. 2. 14. 5. 10. 12. 0. 0.]&lt;br&gt;
 [ 0. 0. 6. 13. 10. 0. 0. 0.]]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the output above, both the digits and the image of the digits are printed. &lt;br&gt;
&lt;em&gt;digits.target&lt;/em&gt; give the ground truth for the digit dataset, i.e., the number corresponding to each digit image. It should be mentioned that data is always a 2D array which has a shape (n_sample, n_features) even though the original data may have had a different shape. In the case of digits, each original sample is an image of shape (8, 8) which can be accessed using &lt;em&gt;digits.image&lt;/em&gt;.&lt;br&gt;
&lt;strong&gt;A look at learning and predicting&lt;/strong&gt;&lt;br&gt;
Using the above work where we have used a dataset sample of 10 possible classes (digits from 0 - 9), we will need to predict the digits when the image is given. To achieve this, we need an estimator which helps to predict the classes to which unseen samples belong. An estimator is a Python object that implements classification using the methods:&lt;br&gt;
&lt;em&gt;fit(x,y)&lt;/em&gt; and &lt;em&gt;predict(T)&lt;/em&gt;. Let’s consider the following example:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;import matplotlib.pyplot as plt&lt;br&gt;
from sklearn import datasets&lt;br&gt;
from sklearn import svm&lt;br&gt;
digits= datasets.load_digits() // dataset&lt;br&gt;
clf = svm.SVC(gamma=0.001, C=100)&lt;br&gt;
print(len(digits.data))&lt;br&gt;
x,y=digits.data[:-1],digits.target[:-1] // train the data&lt;br&gt;
clf.fit(x,y)&lt;br&gt;
print('Prediction:', clf.predict(digits.data[-1])) //predict data&lt;br&gt;
plt.imshow(digits.images[-1],cmap=plt.cm.gray_r, &lt;br&gt;
interpolation="nearest")&lt;br&gt;
plt.show()&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT:&lt;/strong&gt;&lt;br&gt;
_1796&lt;br&gt;
Prediction: [8]&lt;/p&gt;

&lt;p&gt;Image Here…_&lt;/p&gt;

&lt;p&gt;In the above example, we had first found the length and loaded 1796 examples. Next, we have used this data as a learning data, where we need to test the last element and first negative element. Also, we need to check whether the machine has predicted the right data or not. For that, we had used &lt;em&gt;Matplotlib&lt;/em&gt; where we had displayed the image of digits. &lt;br&gt;
In a nutshell, we have digits data, we got the target, we fit and predict it and that’s all.&lt;br&gt;
Now, we can go ahead and visualize the target labels with an image as in the code below:&lt;/p&gt;

&lt;p&gt;_import matplotlib.pyplot as plt&lt;br&gt;
from sklearn import datasets&lt;br&gt;
from sklearn import svm&lt;/p&gt;

&lt;p&gt;digits= datasets.load_digits()&lt;br&gt;
//Join the images and target labels in a list&lt;br&gt;
images_and_labels = list(zip(digits.images, digits.target))&lt;/p&gt;

&lt;p&gt;//for every element in the list&lt;br&gt;
for index, (image, label) in enumerate(images_and_labels[:8]):&lt;br&gt;
    //initialize a subplot of 2X4 at the i+1-th position&lt;br&gt;
    plt.subplot(2, 4, index + 1)&lt;br&gt;
    //Display images in all subplots&lt;br&gt;
    plt.imshow(image, cmap=plt.cm.gray_r,interpolation='nearest')&lt;br&gt;
    //Add a title to each subplot&lt;br&gt;
    plt.title('Training: ' + str(label))&lt;br&gt;
//Show the plot&lt;br&gt;
plt.show()&lt;br&gt;
_&lt;br&gt;
&lt;strong&gt;OUPUT:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Images here…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As can be seen in the code above, we have used the ‘zip’ function to join the images and target labels in a list and then save it into a variable, &lt;em&gt;images_and_labels&lt;/em&gt;. &lt;br&gt;
Then we have indexed the first eight elements in a grid of 2 by 4 at each position and displayed the images with the help of &lt;em&gt;Matplotlib&lt;/em&gt; and added the title as ‘training’.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Technical Guide To Getting Started in Data Science</title>
      <dc:creator>Mukumbuta</dc:creator>
      <pubDate>Mon, 04 Apr 2022 01:09:20 +0000</pubDate>
      <link>https://dev.to/mukumbuta/technical-guide-to-getting-started-in-data-science-3map</link>
      <guid>https://dev.to/mukumbuta/technical-guide-to-getting-started-in-data-science-3map</guid>
      <description>&lt;p&gt;In this guide, “The Ultimate Guide to Getting Started in Data Science”, we will explain more about How to get started in Data Science.&lt;br&gt;
What does a Data Scientist do?&lt;br&gt;
Data science is the study of how to use advanced analytics and scientific principles to get valuable information from data for business decision-making, strategic planning, and other purposes, such as making better business decisions.&lt;br&gt;
To begin with, Data Scientists need data. It could be finance, healthcare, sports, government, industry, research, entertainment, or software engineering – everyone is producing more and more valuable data. Data is so valuable to businesses because it tells them what people want or need. Besides, it tells exactly who likes their product, when they’re buying it, how they’re buying it, how often they’re buying it. &lt;br&gt;
A data scientist’s job is to turn simple, raw, and unprocessed data into an information gold mine. Essentially, data scientists take an ugly big pile of messy data and turn it into a polished conclusion that everyone can understand. Then they give recommended actions to take based on their conclusions.&lt;br&gt;
Below is step-by-step guide on how to get started in data science.&lt;br&gt;
STEP 1: Learn a Programming Language&lt;br&gt;
First things first, if you want to becoming a data scientist, you must learn a programming language. To help you with choosing a programming language among so many, here are a few, but useful tips. &lt;br&gt;
SUPPORTIVE: You want to make sure there’s a big community for it, which you can turn to for advice, like on stack exchange.&lt;br&gt;
POPULAR:  You want lots of pre-written code (libraries) that you can integrate into your own code, like on github. This way, for example, you don’t have to understand how to create a graph from scratch, you can just select the graph you want and feed in your data.&lt;br&gt;
EASY: You also want a language that’s easy to write in, so you don’t make little mistakes that then result in bugs you may spend hours trying to find. This means it’s very easy for you and others to review what you’ve done. &lt;br&gt;
FAST: You want to be able to write programs fast. You want to spend your time analyzing the data not writing code. The faster the programming language lets you create prototypes the better.&lt;br&gt;
POWERFUL: You want to have the option to do long and complex tasks that still run fast and that can be easily integrated into other platforms.&lt;br&gt;
Considering these qualities, the most common programming languages used by data scientists are Python and R. Some other viable ones are JavaScript, C++, Matlab, and SAS. Of course, if you feel more comfortable using another language by all means, do so, at the end of the day whatever you’re fastest in and most comfortable with is what’s best for you!&lt;br&gt;
So now that you have the skills to make your computer crunch data, visualization will set you up to do great analysis and creating comprehensive reports.&lt;br&gt;
Step 2: Make Graphics Your New Best Friends&lt;br&gt;
Visualizations serve two purposes for a data scientist: &lt;br&gt;
 They let you analyze data more easily They make it much easier to communicate what you’ve done with others&lt;br&gt;
 Visualizations play a very important role during your analysis because they let you literally see how your data behaves.&lt;br&gt;
The more you do this, the better you’ll get at being able to differentiate true information (signal) against ones that are just produced through chance (noise).&lt;br&gt;
So, as a data scientist, you’ll be creating the visualizations both to help guide your analysis as well as to visualize results. Once you’ve completed your analysis, if you have to create a report or presentation, you can then pick out the ones that actually say something valuable.&lt;br&gt;
So how can you practice creating and reading these types of graphs? Matplotlib as an amazing library for Python is the answer and a must know for every aspiring data scientist. So I’d highly recommend learning to use that to start making visualizations.&lt;br&gt;
Step 3: Learn How to Analyze Data&lt;br&gt;
A good thing to learn alongside of creating and reading the above types of graphs is how to analyze data. The only way to properly analyze data is to be able to filter, group, drop, aggregate, or manipulate it in other ways. Otherwise, you won’t be able to correctly control and contextualize your analysis, or have the ability to zoom in when answering very specific questions. &lt;br&gt;
Fortunately, Python also has an amazing library for data analysis, called Pandas, that you can just freely download and then use in Python. You can probably start to see why I like Python so much.&lt;br&gt;
As a data scientist you’re going to need data. That data is usually stored in a database. Therefore, you’ll need to learn how to interact with a database.&lt;br&gt;
The most common database type you’ll encounter is an SQL-based database. There are very many different databases that are based on SQL, such as PostgreSQL, Big Query, or MySQL.&lt;br&gt;
SQL databases are also very nice to use because it will speed things up a lot when you start processing, formatting, or even doing part of your analysis in your query, rather than taking out the data and doing all of it afterwards.&lt;br&gt;
 Did you follow the steps above? Boom!! You ‘re a Data Scientist.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Connecting Python to PostgreSQL Database</title>
      <dc:creator>Mukumbuta</dc:creator>
      <pubDate>Fri, 01 Apr 2022 13:41:44 +0000</pubDate>
      <link>https://dev.to/mukumbuta/connecting-python-to-postgresql-database-5bcg</link>
      <guid>https://dev.to/mukumbuta/connecting-python-to-postgresql-database-5bcg</guid>
      <description>&lt;p&gt;Hi. In this article, I'm going to explian how to connect a Python app to PostgreSQL database.&lt;br&gt;
I should be quick to mention that before you can access PostgreSQL databases using Python, you must install one (or more) of the following packages in a virtual environment:&lt;br&gt;
psycopg2: This package contains the psycopg2 module.&lt;br&gt;
PyGreSQL: This package contains the pgdb module.&lt;br&gt;
Both of these packages support Python's portable SQL database API. This means that if you switch from one module to another, you can reuse almost all of your existing code (the code sample below demonstrates how to do this).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up the Python virtual environment and installing a PostgreSQL package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To set up the Python virtual environment and install a PostgreSQL package, follow these steps:&lt;br&gt;
&lt;code&gt;Log in to your account using SSH&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To create a virtual environment, type the following command:&lt;br&gt;
   &lt;code&gt;virtualenv connectDB&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To activate the virtual environment, type the following command:&lt;br&gt;
  &lt;code&gt;source connectDB/bin/activate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The command prompt now starts (connectDB) to indicate that all the operations are now in the Python virtual environment.&lt;br&gt;
We will then update pip before we use to install psycopg2.&lt;/p&gt;

&lt;p&gt;To update pip, enter the following command:&lt;br&gt;
     &lt;code&gt;pip install -U pip&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To install psycopg2 package, enter the following command:&lt;br&gt;
    &lt;code&gt;pip install psycopg2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To install pygresql package, type the following command:&lt;br&gt;
    &lt;code&gt;pip install pygresql&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Having installed PostgreSQL packages in the virtual environment, we are ready to work with actual databases. Let's now demonstrate how to connect to a database with the following sample Python code and switch between the different SQL package implementations using the portable SQL database API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/python 
from __future__ import print_function 
hostname = 'localhost' 
username = 'username' 
password = 'password' 
database = 'dbname'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def doQuery(conn): 
  cur = conn.cursor() 
  cur.execute( "SELECT fname, lname FROM employee" ) 
  for firstname, lastname 
     in cur.fetchall() : 
       print( firstname, 
         lastname ) 
               print( "Using psycopg2:" )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import psycopg2 
myConnection = psycopg2.connect( host=hostname, user=username, password=password, dbname=database ) 
doQuery( myConnection ) 
myConnection.close()
print( "Using PyGreSQL (pgdb):" )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import pgdb 
myConnection = pgdb.connect( host=hostname, user=username, password=password, database=database ) 
doQuery( myConnection ) 
myConnection.close()

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

&lt;/div&gt;



&lt;p&gt;This example creates a series of Connection objects that opens the same database using different PostgreSQL modules. Because both of these modules use the portable SQL database API interface, they are able to use the code in the &lt;strong&gt;doQuery()&lt;/strong&gt; function without any modifications.&lt;br&gt;
When you have a Connection object associated with a database, you can create a Cursor object. The Cursor object enables you to run the &lt;strong&gt;execute()&lt;/strong&gt; method, which in turn enables you to run raw SQL statements (in this case, a SELECT query on a table named employee).&lt;br&gt;
This example creates a Connection object that opens the PostgreSQL database using the specified parameters. Once you have a Connection object associated with the database, you can query the database directly using raw SQL statements (in this case, a SELECT query on a table named employee). The &lt;strong&gt;getresult()&lt;/strong&gt; method reads the result data returned by the query. Finally, the &lt;strong&gt;close()&lt;/strong&gt; method closes the connection to the database.&lt;br&gt;
It is clear, from the above code sample, that Python's portable SQL database API makes it easy to switch between PostgreSQL modules in your code. We only twerk with import and connect to use a different module.&lt;br&gt;
I really hope this was helpful&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Solving Concurrency With PostgreSQL</title>
      <dc:creator>Mukumbuta</dc:creator>
      <pubDate>Thu, 31 Mar 2022 12:34:54 +0000</pubDate>
      <link>https://dev.to/mukumbuta/solving-concurrency-with-postgresql-128k</link>
      <guid>https://dev.to/mukumbuta/solving-concurrency-with-postgresql-128k</guid>
      <description>&lt;p&gt;Databases are an organized way for enterprises to store and use their data. Since most of the data used in an organizational structure are related or interlinked, relational database solutions have been an accepted form of data management for a long time.&lt;br&gt;
A Relational Database Management System (RDBMS) is a system that allows an organization to manage and administer its relational database.&lt;br&gt;
One of the problems that Relational Database Management Systems are solving is concurrency. Usually a developer wants the application to be able to serve multiple users at the same time without going offline for either maintenance or for reconciliation of daily transactional activities in the support system.&lt;br&gt;
Users want to have access to their records and analytical system and see up-to-date records, as to what just happened an instant ago. In the dawn of online and contact-less payment systems and what not, users want to be able to see the bank activities as they happen. In response to this scenario, developers have to give users this experience and let them have everything at their finger tips by providing dashboards that show data that updates in real real-time by sending confirmation text messages immediate the user makes a payment.&lt;br&gt;
The issue will then be how can a developer build such a system that knows how to implement such features? This is where PostgreSQL comes in. &lt;br&gt;
PostgreSQL is the world's most advanced open source relational database, and as a Relational Database Management System (RDBMS), PostgreSQL can handle concurrency and diverse workloads. PostgreSQL can be used to implement transactional system of records and at the same time deliver data analytics.&lt;br&gt;
To be able to achieve the implementation of these activities on top of the same technology, the manager or developer needs a way to express simple transactions and complex analytics aswel. Here is where the developer needs a Structured Query Language (SQL). The Transaction Control Language part of SQL  allows the developer to implement concurrency in the application. &lt;br&gt;
With SQL, the developer can easily implement the CRUD operations. CRUD stands for Create, Read, Update, and Delete.&lt;br&gt;
With SQL, a single statement can take care of a number of rows at the same. This is because SQL is excellent at batching operations. The CRUD operations of the application covers the system of records aspect of the activities and other adminstrative use-cases like creating users, groups, and data organization.&lt;br&gt;
It must be mentioned, though, that some activities are had to implement with SQL. But with Postgres, we access to several extensions that gives us the power to process data right from the database.In distributed systems, the computation can be sent whether data is already, or send the data to the computation nodes.&lt;br&gt;
The beauty of Postgres is that it gives the developer power to choose either to retrieve the data and then process it in the application nodes or choose to process the data right where it is, in the database.&lt;br&gt;
In conclusion, in order to effect concurrency in your application, that is versatile in terms of architecture (CRUD, System of Records, Analyticand Dashboards), and that is powerful in terms of computation, Postgres is the answer. So, if you're not sure with what transactional system to use, and when scaling your application to impossible volumes, try Postgres.&lt;/p&gt;

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