<?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>Forem: AJITH D R</title>
    <description>The latest articles on Forem by AJITH D R (@ajith_56).</description>
    <link>https://forem.com/ajith_56</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%2F1018973%2Ff69ebd54-c5d6-44f9-b714-7bb18111a04b.png</url>
      <title>Forem: AJITH D R</title>
      <link>https://forem.com/ajith_56</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ajith_56"/>
    <language>en</language>
    <item>
      <title>Django Review Points</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Tue, 04 Apr 2023 12:29:45 +0000</pubDate>
      <link>https://forem.com/ajith_56/django-review-points-2fom</link>
      <guid>https://forem.com/ajith_56/django-review-points-2fom</guid>
      <description>&lt;h2&gt;
  
  
  Settings file
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is secret key?
&lt;/h3&gt;

&lt;p&gt;A Secret key is a unique and random string of characters that is used for cryptograpic signing and to protect sensitive information in Django. It is used to sign cookies, CSRF tokens, and other secure data in Django.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the default Django apps inside it? Are there more?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;django.contrib.admin&lt;/code&gt; - provides a web-based admin interface for managing the application data.&lt;br&gt;
&lt;code&gt;django.contrib.auth&lt;/code&gt; - provides authentication functionality.&lt;br&gt;
&lt;code&gt;django.contrib.contenttypes&lt;/code&gt; - allows defining and managing content types for models.&lt;br&gt;
&lt;code&gt;django.contrib.sessions&lt;/code&gt; - provides session management functionality.&lt;br&gt;
&lt;code&gt;django.contrib.messages&lt;/code&gt; - provides a messaging framework for sending notifications and alerts to users.&lt;br&gt;
&lt;code&gt;django.contrib.staticfiles&lt;/code&gt; - provides a way to manage static files such as CSS, JavaScript, and images.&lt;br&gt;
&lt;code&gt;django.contrib.sites&lt;/code&gt; - provides a framework for managing multiple sites on a single Django installation.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is middleware? What are different kinds of middleware?
&lt;/h3&gt;

&lt;p&gt;Read up a little on each security issue.**&lt;br&gt;
Middlware is a set of components that sit between the web server and the view, and can perform various operations on requests/responses. It can be used for modifying requests/responses, authentication, caching and security.&lt;br&gt;
Types of middleware:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Process Request Middleware: It is called before view is executed and can be used to modify the incoming request, authenticate the user, or perform security checks.&lt;/li&gt;
&lt;li&gt;View Middleware: It is called after the view is executed and can be used to modify the response, perform additional authentication or authorization checks, or add additional data to the context.&lt;/li&gt;
&lt;li&gt;Template Response Middleware: It is called after the view has generated a response and can be used to modify the response before it is rendered by the template.&lt;/li&gt;
&lt;li&gt;Exception Middleware: It is called when an exception occurs during the request-response cycle and can be used to handle and log the exception, or display a custom error page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cross-Site Scripting (XSS) Attacks: XSS attacks occur when a malicious user injects script code into a web page, which can then be executed by other users who visit the page. &lt;/li&gt;
&lt;li&gt;Cross-Site Request Forgery (CSRF) Attacks: CSRF attacks occur when a malicious website sends a request to a site on behalf of an authenticated user, without the user's knowledge or consent.&lt;/li&gt;
&lt;li&gt;SQL Injection Attacks: SQL injection attacks occur when a malicious user injects SQL code into a database query, allowing them to access or modify data in the database.&lt;/li&gt;
&lt;li&gt;Authentication and Authorization Issues: Improperly implemented authentication and authorization systems can lead to security vulnerabilities such as password cracking, session hijacking, and privilege escalation.&lt;/li&gt;
&lt;li&gt;File Upload Security: File upload functionality can be vulnerable to security issues such as file tampering and file inclusion attacks.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  What is WSGI
&lt;/h3&gt;

&lt;p&gt;WSGI stands for Web Server Gateway Interface. It's a specification for a universal interface between web servers and web applications or frameworks written in Python. The WSGI specification defines a set of rules and guidelines that enable Python web applications to communicate with web servers. &lt;br&gt;
WSGI allows web servers like Apache or Nginx to talk to Python web applications like Django or Flask. When a request comes into the web server, the server passes the request to the Python web application through the WSGI interface. The application processes the request and returns a response to the web server, which then sends the response back to the client that made the request.&lt;/p&gt;
&lt;h2&gt;
  
  
  Models file
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What is ondelete Cascade?
&lt;/h3&gt;

&lt;p&gt;on_delete=cascade is an option that can be specified when defining a ForeignKey field in a database model. It specifies what should happen when the referenced object in the ForeignKey relationship is deleted.&lt;br&gt;
When on_delete=cascade is specified, it means that when the referenced object is deleted, all objects that have a ForeignKey to it will also be deleted. This behavior is called "cascade deletion".&lt;/p&gt;
&lt;h3&gt;
  
  
  A broad understanding of Fields and Validators available to you
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Fields&lt;/strong&gt; are used to define the types of data that can be stored in a database model. Django provides a wide range of fields for different types of data, such as CharField for short strings, TextField for long text, IntegerField for integers, FloatField for floating-point numbers, BooleanField for true/false values, and many others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Validators&lt;/strong&gt; are used to validate user input in forms. Django provides several built-in validators for different types of data, such as EmailValidator for validating email addresses, MaxLengthValidator for enforcing maximum lengths on text fields, and MinValueValidator for enforcing minimum values on numeric fields. &lt;/p&gt;
&lt;h3&gt;
  
  
  Understanding the difference between Python module and Python class?
&lt;/h3&gt;

&lt;p&gt;A module is a file that contains Python code, usually with a specific purpose or functionality. A module can define functions, classes, variables, and other objects that can be used by other programs or modules.&lt;/p&gt;

&lt;p&gt;A class is a blueprint for creating objects that define a set of attributes and methods. A class is like a template or a factory for creating objects that share common characteristics and behaviors.&lt;/p&gt;
&lt;h2&gt;
  
  
  Django ORM
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Using ORM queries in Django Shell
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Run the Django shell by typing python manage.py shell in the terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you're in the shell, you can import your Django models by typing from my_app.models import Car&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Retrieve all objects from a model&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;all_objects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Retrieve a single object by its primary key
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;single_object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pk&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Filter objects based on specific criteria
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;filtered_objects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mileage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Update an object
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mileage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Delete an object
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Turning ORM to SQL in Django Shell
&lt;/h3&gt;

&lt;p&gt;Every queryset object has query attribute, which holds the actual SQL query which will be sent to Database. query attribute return query when either print or convert it to str.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MyModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What are Aggregations?
&lt;/h3&gt;

&lt;p&gt;Aggregations refer to the process of performing calculations across a set of related objects in the database.&lt;br&gt;
Count - Returns the number of objects in a QuerySet.&lt;/p&gt;

&lt;p&gt;Sum - Calculates the sum of values for a particular field in a QuerySet.&lt;/p&gt;

&lt;p&gt;Avg - Calculates the average value for a particular field in a QuerySet.&lt;/p&gt;

&lt;p&gt;Max - Returns the maximum value for a particular field in a QuerySet.&lt;/p&gt;

&lt;p&gt;Min - Returns the minimum value for a particular field in a QuerySet.&lt;/p&gt;

&lt;p&gt;StdDev - Calculates the standard deviation of a particular field in a QuerySet.&lt;/p&gt;

&lt;p&gt;Variance - Calculates the variance of a particular field in a QuerySet.&lt;/p&gt;
&lt;h3&gt;
  
  
  What are Annotations?
&lt;/h3&gt;

&lt;p&gt;Annotations are used to add calculated fields to QuerySets that are not present in the database. Annotations allow you to perform complex calculations on related objects and add the results to the QuerySet as an additional field.&lt;/p&gt;

&lt;p&gt;Annotations can be used with various aggregation functions and are a powerful tool for customizing the data returned by QuerySets. &lt;/p&gt;

&lt;p&gt;Use an aggregation function to calculate a value for an annotation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.db.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Count&lt;/span&gt;

&lt;span class="c1"&gt;# Add a new field to the QuerySet that counts related objects
&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MyModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;annotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_comments&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'comments'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What is a migration file? Why is it needed?
&lt;/h3&gt;

&lt;p&gt;A migration file is a Python file generated by Django's migration framework that describes changes to a database schema. Migration files are used to manage changes to database models and can be used to create or modify database tables, indexes, constraints, and other schema elements.&lt;br&gt;
Some examples of operations that can be included in a migration file are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a new table&lt;/li&gt;
&lt;li&gt;Adding a new column to an existing table&lt;/li&gt;
&lt;li&gt;Removing a column from an existing table&lt;/li&gt;
&lt;li&gt;Modifying a column in an existing table&lt;/li&gt;
&lt;li&gt;Creating or removing an index&lt;/li&gt;
&lt;li&gt;Creating or removing a constraint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you have created a migration file, you can apply the changes to the database using the migrate management command. This command reads the migration files in your project and applies the changes to the database schema in the correct order.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are SQL transactions? (non ORM concept)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;SQL transactions group a series of database operations into a single unit of work.&lt;/li&gt;
&lt;li&gt;Transactions are atomic, meaning they either succeed or fail as a single unit.&lt;/li&gt;
&lt;li&gt;Transactions must ensure that the database remains in a valid state before and after the transaction.&lt;/li&gt;
&lt;li&gt;Transactions are executed in isolation from other transactions to ensure consistency.&lt;/li&gt;
&lt;li&gt;Once a transaction is committed, its effects are permanent and cannot be undone.&lt;/li&gt;
&lt;li&gt;SQL transactions are used in applications that require reliable and consistent access to a database.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What are atomic transactions?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Atomic transactions are like a single unit of work, where a set of actions are either completed successfully all together, or none of them are executed at all. It's like a switch that turns all the lights on, or none of them, without leaving any halfway states.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In Django's ORM, you can use the atomic decorator or context manager to support atomic transactions. When you wrap a block of code in an atomic block, it guarantees that either all the database operations within that block will succeed, or none of them will be executed at all. This helps to make your code robust and reliable.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>django</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>HTML/CSS Concepts</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Thu, 02 Mar 2023 08:10:44 +0000</pubDate>
      <link>https://forem.com/ajith_56/htmlcss-concepts-5l8</link>
      <guid>https://forem.com/ajith_56/htmlcss-concepts-5l8</guid>
      <description>&lt;h2&gt;
  
  
  Box Model
&lt;/h2&gt;

&lt;p&gt;In web development, the CSS box model is a rectangular structure that encloses each HTML element and includes the content itself, as well as padding, borders, and margins. The below diagram shows these layers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Eh9MBjsX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1j8ooby8zeud00vg0yn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Eh9MBjsX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1j8ooby8zeud00vg0yn.png" alt="Box Model" width="544" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;content: encompasses text and images within the box.&lt;br&gt;
padding: surrounds the content and is transparent&lt;br&gt;
border: outlines the padding and content.&lt;br&gt;
margin: lies outside the border and is transparent.&lt;/p&gt;

&lt;p&gt;If we assume that a box has the following CSS:&lt;br&gt;
The actual space taken up by the box will be 410px wide (350 + 25 + 25 + 5 + 5) and 210px high (150 + 25 + 25 + 5 + 5).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;350px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;150px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GjaQQtlE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mw988jhvttqa2m3w6afn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GjaQQtlE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mw988jhvttqa2m3w6afn.png" alt="Box Model Example" width="500" height="300"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Inline vs Block Elements.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Block-level&lt;/strong&gt; elements are automatically positioned on a new line by browsers and have a margin added before and after the element. They occupy the full available width, extending both to the left and right as far as possible. Examples of popular block-level elements include &amp;lt;p&amp;gt;, &amp;lt;form&amp;gt; , &amp;lt;div&amp;gt;, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An &lt;strong&gt;inline&lt;/strong&gt; element is positioned without starting a new line. An inline element occupies only the required width. Examples of popular inline elements include &amp;lt;span&amp;gt;, &amp;lt;a&amp;gt;, &amp;lt;img&amp;gt;, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Positioning: Relative/Absolute
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Relative Positioning:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When an element is positioned relatively, it remains in the normal flow of the page, but its position can be adjusted relative to its default position.&lt;/li&gt;
&lt;li&gt;The element's position is set using the same top, bottom, left, and right properties as absolute positioning, but the values are relative to the element's original position.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Absolute positioning:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When an element is positioned absolutely, it is removed from the normal flow of the page and positioned relative to its nearest positioned ancestor. If there is no positioned ancestor, it will be positioned relative to the initial containing block.&lt;/li&gt;
&lt;li&gt;The element's position is set using the top, bottom, left, and right properties.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DRrEMM75--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2rd21yc7sbbkgvm30go.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DRrEMM75--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2rd21yc7sbbkgvm30go.png" alt="Positioning" width="602" height="602"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Common CSS structural classes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:first-child&lt;/strong&gt; - Selects first child element under the parent element when first child element is a specified element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:last-child&lt;/strong&gt; - Selects last child element under the parent element when last child element is a specified element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:first-of-type&lt;/strong&gt; - Selects first child element of its type under the parent element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:last-of-type&lt;/strong&gt; - Selects last child element of its type under the parent element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:only-child&lt;/strong&gt; - Selects a specified element if it is the only child element under the parent element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:nth-of-type(n)&lt;/strong&gt; - Selects one or more child elements based on its type under the parent element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:nth-last-of-type(n)&lt;/strong&gt; - Selects one or more child elements based on its type under the parent element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:not&lt;/strong&gt; - This takes simple selector as an argument and selects elements that are not represented by the argument.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:empty&lt;/strong&gt; - Selects empty elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;:root&lt;/strong&gt; - Selects root element.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Common CSS styling classes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Container&lt;/strong&gt;: It is usually defined using the class attribute in HTML and styled in CSS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Row&lt;/strong&gt;: A row class is used to define a horizontal row of elements within a container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Column&lt;/strong&gt;: A column class is used to define a vertical column of elements within a row.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Header&lt;/strong&gt;: A header class is used to define the top section of a web page, which typically includes the site logo, navigation menu, and other important information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Footer&lt;/strong&gt;: A footer class is used to define the bottom section of a web page, which typically includes copyright information, contact details, and links to social media accounts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sidebar&lt;/strong&gt;: It is often used to display additional navigation links or other secondary content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigation&lt;/strong&gt;: A navigation class is used to define a menu of links that allows users to navigate through different sections of the website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Content&lt;/strong&gt;: A content class is used to define the main section of a web page, which typically includes the main text, images, and other media.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  CSS Specificiy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Specificity determines, which CSS rule is applied by the browsers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every selector has its place in the specificity hierarchy. If two selectors apply to the same element, the one with higher specificity wins.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The embedded style sheet has a greater specificity than other rules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ID selectors have a higher specificity than attribute selectors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A class selector beats any number of element selectors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Universal selectors applied at last.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  CSS Responsive Queries
&lt;/h2&gt;

&lt;p&gt;CSS responsive queries are also known as media queries. They allow you to apply different styles to a webpage based on the screen size, orientation, and other characteristics of the device on which it is being viewed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic media query to target smaller screens:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;768px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c"&gt;/* This query targets screens with a maximum width of 768 pixels, and applies styles only when the screen is narrower than that. */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Media query to target larger screens:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;992px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c"&gt;/* This query targets screens with a minimum width of 992 pixels, and applies styles only when the screen is wider than that. */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Flexbox
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Flexbox is a layout mode in CSS that allows you to create flexible and responsive layouts with a single container element and its child elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flexbox has two main axis: the main axis and the cross axis. By default, the main axis is horizontal and the cross axis is vertical.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To use flexbox, we need to set the display property of the container element to flex. For example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To Center the child elements along the main axis.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To center the child elements along the cross axis.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To switch the main axis to vertical.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To allow the child elements to wrap to the next line.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nl"&gt;flex-wrap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Grid
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;CSS grid is a two-dimensional layout system that allows you to create complex layouts for websites.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To create a grid, we need to define a container element and set it to display: grid.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The grid container can be divided into rows and columns using the grid-template-rows and grid-template-columns properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;1&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;2&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;3&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;4&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;5&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;6&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.grid-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;grid-gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.grid-item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ccc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have a grid container with six grid items. We've set the grid-template-columns property to repeat three columns, each with a width of 1fr, and the grid-template-rows property to repeat two rows, each with a height of 100px. We've also added a grid gap of 10px between rows and columns. The result is a 3x2 grid with six equally sized cells.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common header meta tags
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Description tag&lt;/strong&gt; - This tag provides a brief description of the web page.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"This is an example description of the web page."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Keywords tag&lt;/strong&gt; - This tag lists keywords that are relevant to the content on the web page.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"keywords"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"example, keywords, web page"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Author tag&lt;/strong&gt; - This tag specifies the name of the author of the web page.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"author"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"John Doe"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Robots tag&lt;/strong&gt; - This tag specifies whether or not search engine robots should index or follow the web page.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"robots"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"index, follow"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Viewport tag&lt;/strong&gt; - This tag specifies the viewport settings for the web page.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Charset tag&lt;/strong&gt; - This tag specifies the character set used in the web page.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/css/css_boxmodel.asp"&gt;CSS Box Model, W3 Schools&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/The_box_model"&gt;The box model, mdn web docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/"&gt;Absolute, Relative, Fixed Positioning, CSS-TRICKS&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.csssolid.com/css-structural-pseudo-class.html"&gt;CSS Pseudo class selectors explained with example, DOM tree and cheat sheet&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.smashingmagazine.com/2007/07/css-specificity-things-you-should-know/"&gt;CSS Specificity, SmashingMagazine&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-&lt;a href="https://www.w3schools.com/css/css3_flexbox.asp"&gt;CSS Flexbox, W3Schools&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/css/css_grid.asp"&gt;CSS Grid layout Module, W3Schools&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/tags/tag_meta.asp"&gt;HTML meta tag, W3Schools&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Revision - 25/02/2023</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Sat, 25 Feb 2023 06:43:38 +0000</pubDate>
      <link>https://forem.com/ajith_56/revision-25022023-2dh9</link>
      <guid>https://forem.com/ajith_56/revision-25022023-2dh9</guid>
      <description>&lt;p&gt;&lt;strong&gt;1.When do we use UNION operator in SQL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We use UNION operator when we want to combine two or more SELECT statements. UNION also combines two or more tables into a single result set. UNION selects distinct rows and avoids duplicates.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;2.What are the different subsets of SQL?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data Definition Language (DDL): It allows you to perform various operations on the database such as CREATE, ALTER, and DELETE objects.&lt;/li&gt;
&lt;li&gt;Data Manipulation Language(DML): It allows you to access and manipulate data. It helps you to insert, update, delete and retrieve data from the database.&lt;/li&gt;
&lt;li&gt;Data Control Language(DCL): It allows you to control access to the database. Example – Grant, Revoke access permissions.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;3.What are the difference between BCNF and 4NF?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In fourth normal form, there are no multi-valued dependencies of the tables, but in BCNF, there can be multi-valued dependency data in the tables.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;4.If you are working on mutiple git branches how do we switch to a particular branch?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Check all the branches present in git reposiotry&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Switch to particular branch&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout &amp;lt;branchname&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;5.How do you change commit message of previous commit ?&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit --amend -m '&amp;lt;commit message&amp;gt;'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;6.In linux, whenever we run a program, we give flags. Some use '-' and some use '--'. What is the difference ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A single hyphen can be followed by multiple single-character flags. A double hyphen prefixes a single, multicharacter option. &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;7.What are block elements and inline elements in HTML?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Block-level elements are elements that take up the full width of their parent container and create a new line after the element.&lt;/li&gt;
&lt;li&gt;Inline elements, on the other hand, are elements that only take up as much width as necessary and do not create a new line after the element.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;8.What is the kernel and shell, and how are they related ?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The kernel is the core of the operating system that interacts directly with the hardware. The kernel is responsible for managing system processes, scheduling tasks, handling memory management, and managing device drivers.&lt;/li&gt;
&lt;li&gt;The shell, on the other hand, is a user interface that allows users to interact with the operating system. It provides a command-line interface or graphical user interface (GUI) for users to run commands, launch applications, and manage files and directories. &lt;/li&gt;
&lt;li&gt;The kernel and shell are both key components of an operating system. The kernel is responsible for managing system resources and interacting with the hardware, while the shell provides a user interface for users to interact with the operating system. They work together to manage the computer system and execute user commands and tasks.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;9.What is the git command to see all the commits of a particular file?&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --all &amp;lt;file_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;10.What is the use of "eq" dunder method in python ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To change how Python checks if two things are equal using the "==" operator, we can create a special function in our class called "eq". This function will be called when we use the "==" operator on objects of our class. If we don't define this function, Python will use a default method that checks if two objects are stored in the same location in the computer's memory.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;11.What is the difference between rem and em in CSS?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rem stands for "root em", and is always relative to the font-size of the root element (i.e., the html element). For example, if the font-size of the root element is set to 16px, then 1rem is equal to 16px. If the font-size of the root element is changed, then all rem values will be affected accordingly.&lt;/li&gt;
&lt;li&gt;em stands for "element em", and is relative to the font-size of the element that the em value is applied to. For example, if a paragraph element has a font-size of 16px, then 1em is equal to 16px. If the font-size of a parent element is changed, then all em values inside that element will be affected accordingly.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;12.What are mutable objects in python and what is the best way to identify them ?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mutable objects can be changed after they are created.&lt;/li&gt;
&lt;li&gt;The best way to identify whether an object is mutable or not is to try to modify it and see if the modification is reflected in the original object. &lt;/li&gt;
&lt;li&gt;To identify whether an object is mutable or not, we can use the id() function in Python. The id() function returns a unique integer identifier for an object, which can be used to determine if two variables refer to the same object.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_tuple&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="mi"&gt;139941828301888&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_tuple&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="mi"&gt;139941826669696&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_list&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;my_tuple&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="mi"&gt;139941828301888&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_tuple&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="mi"&gt;139941828542624&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see that the list identity is not changed, while the tuple identity is changed. This means that we have expanded our list, but created a completely new tuple. &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;13.Why we should not use multiple inheritance in software development ?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complexity: Multiple inheritance can increase the complexity of a codebase. When a class inherits from multiple parent classes, it may be difficult to determine which parent's implementation of a method should be used in a particular scenario. This can lead to confusion and errors.&lt;/li&gt;
&lt;li&gt;Diamond problem: The diamond problem is a common issue in multiple inheritance where a class inherits from two parent classes that both inherit from a common parent. This can lead to ambiguity in the inheritance hierarchy, making it difficult to determine which parent's implementation should be used.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;14.What is the difference between strongly type and weakly typed language ?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In a strongly typed language, variables have a specific data type, and the language enforces strict rules about how variables of different types can be used. For example, in a strongly typed language like Java, we cannot assign a string value to an integer variable without first converting the string to an integer. The compiler will enforce this rule at compile-time, preventing type-related errors from occurring at runtime.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In a weakly typed language, variables are not required to have a specific data type, and the language may automatically convert between different data types as needed. For example, in a weakly typed language like JavaScript, we can assign a string value to a variable declared as an integer, and the language will automatically convert the string to an integer if possible.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;15.What is the difference between statically typed and dynamically typed language?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Statically typed languages requires to declare the data type of a variable before it can be used. This means that the compiler can check the type of each variable at compile time, ensuring that only values of the correct type are assigned to each variable. Examples of statically typed languages include Java, C++, and C#.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dynamically typed languages, on the other hand, do not require variables to be declared with a specific data type. Instead, the type of a variable is determined at runtime based on the value assigned to it. This allows for more flexibility in programming and can make the code easier to read and write. Examples of dynamically typed languages include Python, Ruby, and JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;16.How do you give space between flex items (CSS) ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using gap property. The gap property sets the gaps between rows and columns. It is a shorthand for row-gap and column-gap.&lt;/p&gt;

</description>
      <category>c</category>
      <category>programming</category>
    </item>
    <item>
      <title>SQL Concepts</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Wed, 22 Feb 2023 06:25:45 +0000</pubDate>
      <link>https://forem.com/ajith_56/sql-concepts-202k</link>
      <guid>https://forem.com/ajith_56/sql-concepts-202k</guid>
      <description>&lt;h2&gt;
  
  
  ACID Properties
&lt;/h2&gt;

&lt;p&gt;ACID properties are a set of properties that ensures the consistent state before and after the transaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Atomicity:
&lt;/h3&gt;

&lt;p&gt;Atomicity property says that, when an action is performed on the data, it should either be executed completely or not executed at all.&lt;/p&gt;

&lt;p&gt;Suppose there's an application that transfers funds between accounts. In this case, the property of atomicity guarantees that when a withdrawal is made from one account, the corresponding deposit is also made to the other account, ensuring a successful transaction. If any part of the transaction fails  due to insufficient funds, the entire transaction is rolled back to its initial state.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Consistency:
&lt;/h3&gt;

&lt;p&gt;The consistency property of a transaction ensures that the data is in a valid state both before the transaction begins and after it completes.&lt;/p&gt;

&lt;p&gt;For instance, when performing a fund transfer from one account to another, the consistency property guarantees that the total amount of funds in both accounts remains constant at the beginning and end of each transaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Isolation:
&lt;/h3&gt;

&lt;p&gt;In a system where multiple transactions are running simultaneously, the intermediate phase of each transaction is not visible to other transactions. This implies that the concurrent transactions seem to be executed sequentially.&lt;/p&gt;

&lt;p&gt;For instance, suppose an application that transfers funds from one account to another. In that case, the isolation property guarantees that any other transaction will only see the transferred funds in one account or the other, but not in both accounts or neither of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  4: Durability:
&lt;/h3&gt;

&lt;p&gt;Once a transaction has been executed successfully, any modifications made to the data are permanent and will not be reverted, even if there is a system malfunction.&lt;/p&gt;

&lt;p&gt;For instance, consider an application that transfers money from one account to another. In such a scenario, the durability property ensures that any modifications made to the accounts involved in the transaction will be preserved and will not be rolled back.&lt;/p&gt;




&lt;h2&gt;
  
  
  CAP Theorem
&lt;/h2&gt;

&lt;p&gt;CAP theorem states that, In a distributed systems, it is not possible to guarantee all three properties - consistency, availability, and partition tolerance at the same time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt; means that all nodes will have same data at the same time. Every client will read the same data no matter what node they are connected to.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Availability&lt;/strong&gt; ensures that even if one or more nodes are down, any client making a request to a node for data will gets a response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Partition&lt;/strong&gt; tolerance means that the system must continue working even if there is a communication break within the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Since the networks are not completely reliable, we must tolerate partitions in a distributed systems. According to CAP theorem, we can have only two properties at the same time, so with partition tolerance we can have consistency or availability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CP:&lt;/strong&gt; CP based system provides consistency and partition tolerance. When a communication break occurs between any two nodes, the system has to make the non-consistent node unavailable till the partition is resolved.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AP:&lt;/strong&gt; AP based systems provides availability and partition tolerance.&lt;br&gt;
When a communication break occurs, all nodes will be available to the clients but non-consistent nodes might return older data than other nodes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Joins
&lt;/h2&gt;

&lt;p&gt;Joins in SQL is used to combine columns of two or more tables based on the common columns between the tables being joined.&lt;br&gt;
There are various types of joins:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inner join&lt;/li&gt;
&lt;li&gt;Left join&lt;/li&gt;
&lt;li&gt;Right join&lt;/li&gt;
&lt;li&gt;Full join&lt;/li&gt;
&lt;li&gt;Self join&lt;/li&gt;
&lt;li&gt;Cross join&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The examples that I have used here are sourced from &lt;a href="https://www.tutorialspoint.com/sql/sql-using-joins.htm" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;br&gt;
Consider the following two tables:&lt;br&gt;
Table 1 - CUSTOMERS Table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxm6o0bp1v4aphlauqyd8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxm6o0bp1v4aphlauqyd8.png" alt="Customers table" width="579" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Table 2 - ORDERS Table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyksn9ith581wyu5mb7u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyksn9ith581wyu5mb7u.png" alt="Order table" width="589" height="234"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  INNER JOIN:
&lt;/h3&gt;

&lt;p&gt;INNER JOIN is also referred to as EQUIJOIN. It joins all rows from the intended tables if they meet the stated condition.&lt;br&gt;
If we want to get all the records from two tables that have common customer id, we can get it using inner join.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT  ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
INNER JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will produce the following output:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nh4n3xa1awfgz2eur9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nh4n3xa1awfgz2eur9p.png" alt="Inner Join example" width="516" height="211"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  LEFT JOIN:
&lt;/h3&gt;

&lt;p&gt;Left Join returns all the records from the Left Table and only the matching records from the right table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT  ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
LEFT JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F220ztq0rxa7qcev78ick.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F220ztq0rxa7qcev78ick.png" alt="LEFT JOIN example" width="515" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  RIGHT JOIN:
&lt;/h3&gt;

&lt;p&gt;Right Join returns all the records from the Right table and only the matching records from the left table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT  ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
RIGHT JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6fdxrqhwa4mo1hmpn7p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6fdxrqhwa4mo1hmpn7p.png" alt="RIGHT JOIN example" width="539" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  FULL JOIN:
&lt;/h3&gt;

&lt;p&gt;The SQL FULL JOIN combines the results of both left and right joins.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT  ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
FULL JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgoglldu63eh5otnpc78.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgoglldu63eh5otnpc78.png" alt="FULL JOIN example" width="526" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  SELF JOIN:
&lt;/h3&gt;

&lt;p&gt;The SELF JOIN is used to join a table to itself. This means that each row in a table is joined to itself and every other row in that table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT  a.ID, b.NAME, a.SALARY
FROM CUSTOMERS a, CUSTOMERS b
WHERE a.SALARY &amp;lt; b.SALARY;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fof14i19wkvvy5ukitaq9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fof14i19wkvvy5ukitaq9.png" alt="SELF JOIN example" width="292" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cross Join:
&lt;/h3&gt;

&lt;p&gt;Cross Join returns the cartesian product of the two tables. That means, it produces a paired combination of each row of the first table with each row of the second table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT  ID, NAME, AMOUNT, DATE
FROM CUSTOMERS, ORDERS;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa04rlchq8as46gxx8581.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa04rlchq8as46gxx8581.png" alt="Cross Join example" width="438" height="722"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Aggregations, Filters in queries:
&lt;/h2&gt;

&lt;p&gt;Aggregate function operates on a set of values and returns a single value.&lt;/p&gt;

&lt;p&gt;Consider the following table 'Random_numbers':&lt;/p&gt;

&lt;p&gt;numbers&lt;br&gt;
12&lt;br&gt;
10&lt;br&gt;
13&lt;br&gt;
97&lt;br&gt;
100   &lt;/p&gt;

&lt;p&gt;Commonly used SQL Aggregate functions are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;COUNT():&lt;/strong&gt; This function returns the number of items in a set.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT COUNT(numbers) FROM Random_numbers;

-- output: 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AVG():&lt;/strong&gt; This function returns the average of a set.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT AVG(numbers) FROM Random_numbers;

-- output: 46.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SUM():&lt;/strong&gt; This function returns the sum of all values in a set.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT SUM(numbers) FROM Random_numbers;

-- output: 232
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MIN():&lt;/strong&gt; This function returns the minimum value in a set.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT MIN(numbers) FROM Random_numbers;

-- output: 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MAX():&lt;/strong&gt; This function returns the maximum value in a set.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT MAX(numbers) FROM Random_numbers;

-- output: 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Filters:&lt;/p&gt;
&lt;h4&gt;
  
  
  AND:
&lt;/h4&gt;

&lt;p&gt;The AND operator allows the existence of multiple conditions in an SQL statement WHERE clause&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT CustomerID, InvoiceId, Total
FROM Invoice
WHERE Total &amp;gt;= 10 AND Total =&amp;lt; 13;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  OR:
&lt;/h4&gt;

&lt;p&gt;The OR operator combines multiple conditions in an SQL statement’s WHERE clause.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT FirstName, LastName, City 
FROM Customer 
WHERE City = 'London' OR City ='Paris' OR City='Milan';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  NOT:
&lt;/h4&gt;

&lt;p&gt;The NOT operator reverses the meaning of the logical operator with which it is used; eg, NOT BETWEEN, NOT IN.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT FirstName, LastName, City
FROM Customer
WHERE City NOT IN ('London', 'Paris', 'Milan');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  BETWEEN:
&lt;/h4&gt;

&lt;p&gt;The BETWEEN operator searches for values that are within a set of values, given the minimum value and the maximum value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT CustomerID, InvoiceId, Total
FROM Invoice
WHERE Total BETWEEN 10 AND 13;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  IN:
&lt;/h4&gt;

&lt;p&gt;The IN operator compares a value with a list of literal values that have been specified.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT FirstName, LastName, City 
FROM Customer 
WHERE City IN ('London', 'Paris', 'Milan');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  LIKE:
&lt;/h4&gt;

&lt;p&gt;The LIKE operator compares a value with similar values, using wildcard operators.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Composer, Name 
FROM Track 
WHERE Name LIKE '%Rock%';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Normalization
&lt;/h2&gt;

&lt;p&gt;Normalization helps to reduce or remove data redundancy in a database. It is important to remove redundancy since it causes anomalies in a database which makes it hard to maintain it.&lt;/p&gt;

&lt;p&gt;There are four types of normal forms:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First Normal Form (1NF)&lt;/strong&gt;&lt;br&gt;
For a table to be in the First Normal Form,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It should only have atomic valued attributes.&lt;/li&gt;
&lt;li&gt;Values stored in a column should be of the same domain.&lt;/li&gt;
&lt;li&gt;All the columns in a table should have unique names.&lt;/li&gt;
&lt;li&gt;And the order in which data is stored, does not matter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Second Normal Form (2NF)&lt;/strong&gt;&lt;br&gt;
For a table to be in the Second Normal Form,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It should be in the First Normal Form.&lt;/li&gt;
&lt;li&gt;And, it should not have Partial Dependency(Non prime attribute(s) should not depend on part of the candidate key).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Third Normal Form (3NF)&lt;/strong&gt;&lt;br&gt;
For a table to be in the Third Normal Form,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It should be in the Second Normal Form.&lt;/li&gt;
&lt;li&gt;It should not have Transitive Dependency(A functional dependency X → Y in a relation R is a transitive dependency if there is a set of attributes Z that is not a subset of any key of R, and both X → Z and Z → Y hold).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Boyce-Codd Normal Form (BCNF)&lt;/strong&gt;&lt;br&gt;
For a table to be in BCNF, it must satisfy the following rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The table must be in the third normal form.&lt;/li&gt;
&lt;li&gt;For every non-trivial functional dependency X -&amp;gt; Y, X is the superkey of the table. That means X cannot be a non-prime attribute if Y is a prime attribute. A superkey is a set of one or more attributes that can uniquely identify a row in a database table.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Indexes
&lt;/h2&gt;

&lt;p&gt;Indexing is a technique used to optimize the speed of retrieving data. Indexing helps to speed up queries by allowing the database to quickly find the relevant data.&lt;/p&gt;

&lt;p&gt;For example, consider a table called 'Employees' which contains information about employees, such as their firstname, lastname, emailId, Salary, location. Now if we want to search for all the employees who live in a particular location, the DBMS will scan the entire table to find the required records which makes it slower.&lt;br&gt;
But, if we create an index on the location, the DBMS use that index to quickly find the required records.&lt;br&gt;
Example to create an index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE INDEX employees_by_location
ON Employees (location)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Transactions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Transaction is a set of operations performed on a database, which is treated as a single operation. &lt;/li&gt;
&lt;li&gt;A transaction can include multiple operations on the database, but if any one of those operations fails, the entire transaction is rolled back, and the database returns to its original state. &lt;/li&gt;
&lt;li&gt;Transaction has four properties which maintains consistency in a database, before and after transaction: Atomicity, Consistency, Isolation and Durability.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Locking Mechanism
&lt;/h2&gt;

&lt;p&gt;The locking mechanism allows the database to produce sequential output without sequential steps. Locks provide a way to protect data in use from anomalies, such as data loss or additional data that may be added due to a lost transaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two-Phase Locking Protocol&lt;/strong&gt;&lt;br&gt;
Each transaction locks and unlocks items in two different steps.&lt;/p&gt;

&lt;p&gt;Growth Phase - All locks are executed in this phase. Locks are not released after the second phase (compact phase) starts after all changes have been committed.&lt;/p&gt;

&lt;p&gt;Compact Phase - In this phase no locks are issued, all changes to the data item are saved and then the locks are released.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa1cskjfmrrl47u8mj8bp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa1cskjfmrrl47u8mj8bp.png" alt="2 Phase Locking" width="440" height="299"&gt;&lt;/a&gt;&lt;br&gt;
In the grow phase, a transaction reaches a point where it has already acquired all the locks it needs. This point is called the LOCK POINT.&lt;/p&gt;

&lt;p&gt;After reaching the blocking point, the transaction enters the compression phase.&lt;/p&gt;


&lt;h2&gt;
  
  
  Database Isolation Levels
&lt;/h2&gt;

&lt;p&gt;Database isolation levels refer to the degree to which different transactions in a database are isolated from one another.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Read Uncommitted(Level 0):&lt;/strong&gt; This isolation level allows transactions to read uncommitted data that has not yet been written to the database. This can lead to dirty reads, where transactions read data that has been modified by another transaction but has not yet been committed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Read Committed (Level 1):&lt;/strong&gt; This isolation level prevents other transactions from writing to or reading from rows that other transactions have written but have not yet committed. So it doesn't allow dirty reading. A transaction holds a read or write lock on the current row, so other transactions cannot read, update, or delete that row.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Repeatable Read (Level 2):&lt;/strong&gt; This isolation level ensures that any transaction that reads data from a row blocks other write transactions accessing the same row. This is the most restrictive isolation level and holds read locks on all rows it references and holds write locks on all rows it inserts, updates, or deletes. No other transaction can read, update, or delete these rows, preventing non-repeatable reads.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Serializable (Level 3):&lt;/strong&gt; This isolation level is the highest isolation level. A serializable isolation level requires much more than restricting access to a single row. Typically, this isolation mode locks the entire table to prevent other transactions from inserting or reading data from the table.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Triggers
&lt;/h2&gt;

&lt;p&gt;Trigger are the SQL statements that runs automatically in response to certain events or changes to a table. Triggers can be used to perform actions such as updating a table or sending an email whenever specific data is inserted, updated, or deleted from a table.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create trigger Trigger_name
(before | after)
[insert | update | delete] 
on [table_name]  
[for each row]  
[trigger_body]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"CREATE TRIGGER" - Used to make a new trigger. &lt;br&gt;
"TRIGGER_NAME" - Name of the trigger, and it has to be unique. &lt;br&gt;
"BEFORE" or "AFTER" - Specifies when the trigger should happen, either before or after an event. &lt;br&gt;
"INSERT", "UPDATE", or "DELETE" - Events that can activate the trigger. &lt;br&gt;
"ON [TABLE_NAME]" - Specifies the table that the trigger is connected to. &lt;br&gt;
"FOR EACH ROW" - means the trigger is triggered for each row in the table. &lt;br&gt;
"TRIGGER_BODY" contains the SQL queries that the trigger will execute when it's activated.&lt;/p&gt;

&lt;p&gt;Here's a simple SQL trigger example that automatically updates a "last_updated" column in a table called "orders" whenever a new row is inserted into the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TRIGGER update_last_updated
AFTER INSERT ON orders
FOR EACH ROW
BEGIN
   UPDATE orders
   SET last_updated = NOW()
   WHERE id = NEW.id;
END;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.ibm.com/docs/en/cics-ts/5.4?topic=processing-acid-properties-transactions" rel="noopener noreferrer"&gt;ACID properties of transactions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.ibm.com/in-en/topics/cap-theorem" rel="noopener noreferrer"&gt;CAP Theorem, IBM&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.tutorialspoint.com/sql/sql-using-joins.htm" rel="noopener noreferrer"&gt;SQL - Using Joins, TutorialsPoint&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.studytonight.com/dbms/database-normalization.php" rel="noopener noreferrer"&gt;Normalization of Database, StudyTonight&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.futurelearn.com/info/courses/data-analytics-for-business-manipulating-and-interpreting-your-data/0/steps/177501" rel="noopener noreferrer"&gt;How to Filter Query Results in SQL&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.tutorialspoint.com/explain-about-two-phase-locking-2pl-protocol-dbms" rel="noopener noreferrer"&gt;Two phase Locking Protocol, TutorialsPoint&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/nerd-for-tech/understanding-database-isolation-levels-c4ebcd55c6b9" rel="noopener noreferrer"&gt;Understanding Database Isolation Levels&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://afteracademy.com/blog/what-is-a-trigger-in-dbms/" rel="noopener noreferrer"&gt;What is a Trigger in DBMS&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>SOLID Design Principles</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Mon, 20 Feb 2023 06:46:10 +0000</pubDate>
      <link>https://forem.com/ajith_56/solid-design-principles-1576</link>
      <guid>https://forem.com/ajith_56/solid-design-principles-1576</guid>
      <description>&lt;p&gt;SOLID Design Principles are a set of five design principles introduced by Robert C. Martin. These principles help developers build maintainable, flexible and scalable software systems.&lt;br&gt;
SOLID is an acronym for the following design principles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;S&lt;/strong&gt;ingle Responsibility Principle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;O&lt;/strong&gt;pen-Closed Principle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L&lt;/strong&gt;iskov Substitution Principle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I&lt;/strong&gt;nterface Segregation Principle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;D&lt;/strong&gt;ependency Inversion Principle.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Single Responsibility Principle(SRP):
&lt;/h2&gt;

&lt;p&gt;SRP says that a class should have only one responsibility and should have only one reason to change.&lt;/p&gt;

&lt;p&gt;For instance, we have a class called 'Order' that represents a customer's order at a restaurant. The Order class has two responsibilities: handling the order items and printing the receipt.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Order:
    def __init__(self, order_items):
        self.order_items = order_items

    def calculate_total(self):
        # logic to calculate total cost of order
        pass

    def print_receipt(self):
        # logic to print receipt
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above implementation violates SRP since it has two responsibilities. We can separate these responsibilities into two classes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Order:
    def __init__(self, order_items):
        self.order_items = order_items

    def calculate_total(self):
        # logic to calculate total cost of order
        pass

class ReceiptPrinter:
    def print_receipt(self, order):
        # logic to print receipt
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 'Order' class is now responsible for handling the order items, and the 'ReceiptPrinter' class is responsible only for printing the receipt. This separation makes it easier to update or replace the receipt printing logic in the future without affecting the 'Order' class.&lt;/p&gt;




&lt;h2&gt;
  
  
  Open-Closed Principle(OCP):
&lt;/h2&gt;

&lt;p&gt;The OCP states "Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification".&lt;/p&gt;

&lt;p&gt;Suppose we have an existing 'Product' class that represents a product in the store, with properties such as 'name', 'price' and 'description'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Product:
    def __init__(self, name, price, description):
        self.name = name
        self.price = price
        self.description = description

    def get_price(self):
        return self.price
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now suppose we were to add a new feature where we offer discounts on certain products. We can apply OCP here by creating a new 'DiscountProduct' subclass that inherits 'Product' class without modifying the 'Product' class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Product:
    def __init__(self, name, price, description):
        self.name = name
        self.price = price
        self.description = description

    def get_price(self):
        return self.price

class DiscountedProduct(Product):
    def __init__(self, name, price, description, discount):
        super().__init__(name, price, description)
        self.discount = discount

    def get_price(self):
        discounted_price = super().get_price() - self.discount
        return max(discounted_price, 0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 'DiscountedProduct' class overrides the 'get_price' method of the Product class to return the discounted price of the product.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Usage
product = Product("Shirt", 20, "A basic shirt")
print("Product price:", product.get_price())

discounted_product = DiscountedProduct("Jacket", 100, "A warm jacket", 25)
print("Discounted product price:", discounted_product.get_price())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By applying the OCP in the above example, we have made our code more maintainable and flexible. If we want to add new features in the future, we can create new subclasses of 'Product' without modifying existing code. This makes our code more scalable and less prone to errors.&lt;/p&gt;




&lt;h2&gt;
  
  
  Liskov substitution principle(LSP):
&lt;/h2&gt;

&lt;p&gt;Liskov Substitution Principle states that "Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program."&lt;/p&gt;

&lt;p&gt;Let’s take an example of class 'Car' that would indicate the type of a car. The 'PetrolCar' class inherits the 'Car' class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car:
    def __init__(self, type):
        self.type = type

class PetrolCar(Car):
    def __init__(self, type):
        self.type = type

car = Car('SUV'):
car.properties = {'color': 'Red', 'gear': 'Auto', 'capacity': 6}
print(car.properties)

petrol_car = PetrolCar('Sedan')
petrol_car.properties = ('Blue', 'Manual', 4)
print(petrol_car.properties)

Output:
{'color': 'Red', 'gear': 'Auto', 'capacity': 6}
('Blue', 'Manual', 4)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, adding car properties does not follow any standard and it is upto the developers to implement it as a dictionary or tuple or other ways. &lt;/p&gt;

&lt;p&gt;Now, if we want to find all the red-coloured cars based on the current implementation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cars = [car, petrol_car]

def find_red_cars(cars):
    red_cars = 0
    for car in cars:
        if car.properties['color'] == 'Red':
            red_cars += 1
    print(f'Number of Red Cars = {red_cars}')

find_red_cars(cars)

# TypeError: tuple indices must be integers or slices, not str
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the implementation breaks the LSP as we cannot replace Car's object with its subclass PetrolCar's object in the function written to find red-colored cars.&lt;/p&gt;

&lt;p&gt;So how can we fix this?, we can implement getters and setters methods in the Car's class using which we can set and get the properties of the Car without leaving the decision to developers on how to implement Car's properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car:
    def __init__(self, type):
        self.type = type
        self.car_properties = {}

    def set_properties(self, color, gear, capacity):
        self.car_properties = {'color': color, 'gear': gear, 'capacity': capacity}

    def get_properties(self):
        return self.car_properties

class PetrolCar(Car):
    def __init__(self, type):
        self.type = type
        self.car_properties = {}

car = Car('SUV'):
car.set_properties('Red', 'Auto', 6)

petrol_car = PetrolCar('Sedan')
petrol_car.set_properties('Blue', 'Manual', 4)

cars = [car, petrol_car]

def find_red_cars(cars):
    red_cars = 0
    for car in cars:
        if car.get_properties()['color'] == 'Red':
            red_cars += 1
    print(f'Number of Red Cars = {red_cars}')

find_red_cars(cars)

Output: Number of Red Cars = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Interface Segregation Principle(ISP):
&lt;/h2&gt;

&lt;p&gt;The ISP states that clients should not be forced to depend on methods they do not use. In other words, it is better to have multiple small interfaces, each serving a specific purpose, rather than a single large interface with many methods.&lt;br&gt;
Suppose we have a Communicator interface that includes methods for making calls, sending messages, and browsing the internet.&lt;/p&gt;

&lt;p&gt;Now, if we want to implement a Landline phone which is a communication device, we create a new class LandlinePhone using the same CommunicationDevice interface. This is exactly when we face the problem due to a large CommunicationDevice interface we created. In the class LanlinePhone, we implement the make_calls() method, but as we also inherit abstract methods send_sms() and browse_internet() we have to provide an implementation of these two abstract methods also in the LandlinePhone class even if these are not applicable to this class LandlinePhone. We can either throw an exception or just write pass in the implementation, but we still need to provide an implementation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from abc import ABC, abstractmethod

class Communicator(ABC):
    @abstractmethod
    def make_call(self, number):
        pass

    @abstractmethod
    def send_message(self, number, message):
        pass

    @abstractmethod
    def browse_internet(self):
        pass

class SmartPhone(CommunicationDevice):
  def make_calls(self, number):
    #implementation
    pass

  def send_sms(self, number, message):
    #implementation
    pass

  def browse_internet(self):
    #implementation
    pass

  class LandlinePhone(CommunicationDevice):
    def make_calls(self, number):
      #implementation
      pass

    def send_sms(self, number, message):
      #just pass or raise exception as this feature is not supported 
      pass

    def browse_internet(self):
      #just pass or raise exception as this feature is not supported
      pass 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of creating a large interface, we can create a smaller interfaces for each method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from abc import ABC, abstractmethod

class CallingDevice:
  @abstractmethod
  def make_calls(self, number):
    pass

class MessagingDevice:
  @abstractmethod
  def send_sms(self, number, message):
    pass

class InternetbrowsingDevice:
  @abstractmethod
  def browse_internet(self):
    pass

class SmartPhone(CallingDevice, MessagingDevice, InternetbrowsingDevice):
  def make_calls(self, number):
    #implementation
    pass

  def send_sms(self, number, message):
    #implementation
    pass

  def browse_internet(self):
    #implementation
    pass

class LandlinePhone(CallingDevice):
  def make_calls(self, number):
    #implementation
    pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Dependency Inversion Principle(DIP):
&lt;/h2&gt;

&lt;p&gt;The Dependency Inversion Principle states that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;High level module should not depend on low level modules. Both should depend on abstractions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Abstractions should not depend on details. Details should depend on abstractions.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class LightSwitch:
    def __init__(self, light):
        self.light = light

    def turn_on(self):
        self.light.turn_on()

    def turn_off(self):
        self.light.turn_off()

class Light:
    def turn_on(self):
        # Code to turn on the light

    def turn_off(self):
        # Code to turn off the light
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the LightSwitch class depends on the Light class to turn the light on and off. However, this violates the DIP, since the LightSwitch is a high-level module and Light is a low-level module.&lt;/p&gt;

&lt;p&gt;To fix this, we can invert the dependency by introducing abstraction.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from abc import ABC, abstractmethod

class Switchable(ABC):
    @abstractmethod
    def turn_on(self):
        pass

    @abstractmethod
    def turn_off(self):
        pass

class LightSwitch:
    def __init__(self, switchable):
        self.switchable = switchable

    def turn_on(self):
        self.switchable.turn_on()

    def turn_off(self):
        self.switchable.turn_off()

class Light(Switchable):
    def turn_on(self):
        # Code to turn on the light

    def turn_off(self):
        # Code to turn off the light
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the 'LightSwitch' class relies on the 'Switchable' interface rather than the 'Light' class directly. This ensures that the high-level module ('LightSwitch') depends on an abstraction('Switchable'), rather than low-level module('Light') directly.&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.linkedin.com/pulse/solid-design-principles-python-examples-hiral-amodia" rel="noopener noreferrer"&gt;SOLID Design Principles with Python Examples, Hiral Amodia&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/SOLID" rel="noopener noreferrer"&gt;SOLID, wikipedia&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.youtube.com/playlist?list=PLTCrU9sGybuq3Jz51xfT3mA2BIVNDHwIV" rel="noopener noreferrer"&gt;SOLID Principles Made Easy, sudoCODE&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Object Oriented Programming in Python</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Thu, 16 Feb 2023 06:48:16 +0000</pubDate>
      <link>https://forem.com/ajith_56/object-oriented-programming-in-python-3nlp</link>
      <guid>https://forem.com/ajith_56/object-oriented-programming-in-python-3nlp</guid>
      <description>&lt;h2&gt;
  
  
  What is Object Oriented Programming?
&lt;/h2&gt;

&lt;p&gt;Object-oriented programming(OOP) is a way of writing computer programs that revolves around the concept of objects. An object is a combination of data and the functions that operate on that data.&lt;/p&gt;

&lt;p&gt;For instance, an object could represent a person with attributes like a name, age, emailId, address and behaviors like walking, breathing, talking and running.&lt;/p&gt;

&lt;p&gt;By using OOP, we can create modular, reusable code that is easier to maintain and extend.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to define a Class:
&lt;/h2&gt;

&lt;p&gt;The beginning of a class definition requires the use of the "class" keyword followed by the class name and a colon. Any code that is inside the indented block of this class definition is considered to be a part of the class's body.&lt;/p&gt;

&lt;p&gt;Here's an example of Person class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The _&lt;em&gt;init_&lt;/em&gt;() method is a special method that gets called when a new instance of the class is created, and here it sets the initial values for the name and age attributes.&lt;br&gt;
'self' is a reference to the instance of the class that is being created when the _&lt;em&gt;init_&lt;/em&gt; method is called.&lt;/p&gt;

&lt;p&gt;To create an instance of the 'Person' class, you can simply call a function and pass in the necessary arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;person = Person('Alice', 25)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a new Person object with the name "Alice" and age 25.&lt;/p&gt;




&lt;h2&gt;
  
  
  Class and Instance Attributes:
&lt;/h2&gt;

&lt;p&gt;In Python, a class attribute is a variable that is associated with a class, whereas an instance attribute is a variable that is associated with an instance of the class. Here are some examples of how to define and use class and instance attributes in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person:
    species = "human"

    def __init__(self, name, age):
        self.name = name
        self.age = age
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;'species' is a class attribute of the Person class, which is associated with the class itself, not with any particular instance of the class. &lt;/li&gt;
&lt;li&gt;The value of species is shared by all instances of the Person class. &lt;/li&gt;
&lt;li&gt;We can access the class attribute using the class name and instance attributes using the instance variable.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(Person.species)  # "human"

person = Person("Alice", 25)
print(person.name) # "Alice"
print(person.age) # 25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Types of methods
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instance Methods:&lt;/strong&gt; Instance methods are the most common type of method in Python. They are associated with an instance of the class and can access and modify the instance's state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Class Methods:&lt;/strong&gt; Class methods are bound to the class rather than the instance. They can be used to modify the class state or perform operations that are not specific to any instance of the class. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Static Methods:&lt;/strong&gt; Static methods do not depend on the class or instance state. They are often used for utility functions that do not modify the class or instance state&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person:
    num_people = 0

    def __init__(self, name, age):
        self.name = name
        self.age = age
        Person.num_people += 1

    def say_hello(self):
        print(f"Hello, my name is {self.name}.")

    @classmethod
    def num_instances(cls):
        print(f"{cls.num_people} People instances are created.")

    @staticmethod
    def is_adult(age):
        return age &amp;gt;= 18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The class variable 'num_people' keeps track of the total number of Person objects that have been created.&lt;/li&gt;
&lt;li&gt;The _&lt;em&gt;init_&lt;/em&gt;() method sets the name and age attributes for each Person object and increments the num_people class variable.&lt;/li&gt;
&lt;li&gt;The say_hello() method is an instance method that prints a message that includes the person's name.&lt;/li&gt;
&lt;li&gt;The num_instances() method is a class method that prints the total number of Person objects that have been created.&lt;/li&gt;
&lt;li&gt;The is_adult() method is a static method that takes an age argument and returns a Boolean value indicating whether the person is an adult.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;person1 = Person("Alice", 30)
person2 = Person("Bob", 25)

person1.say_hello()  # Output: "Hello, my name is Alice."
person2.say_hello()  # Output: "Hello, my name is Bob."

Person.num_instances()  # Output: "2 People instances are created."

print(Person.is_adult(person1.age))  # Output: True
print(Person.is_adult(person2.age))  # Output: True
print(Person.is_adult(16))  # Output: False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Inheritance:
&lt;/h2&gt;

&lt;p&gt;Inheritance allows one class to inherit properties and methods from another class. In Python, we can create a subclass by specifying the parent class in parentheses after the subclass name. &lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Inheritance:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Single inheritance:&lt;/strong&gt; A subclass inherits from superclass.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

class Student(Person):
    def __init__(self, name, age, id):
        super().__init__(name, age)
        self.id = id

student = Student("Alice", 20, "12345")

print(student.name)        # Output: Alice
print(student.age)         # Output: 20
print(student.student_id)  # Output: 12345
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the Student class inherits from the Person class, so it gets access to the name and age attributes defined in the Person class.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multiple inheritance:&lt;/strong&gt; A subclass inherits from multiple superclasses.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class A:
    def dothis(self):
        print('do this in A')

class B(A):
    pass

class C:
    def dothis(self):
        print('do this in C')

class D(B, C):
    pass

d_instance = D()
d_instance.dothis()  #do this in A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the 'D' class inherits both the 'B' and 'C' classes, allowing it to access their attributes and methods.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multilevel inheritance:&lt;/strong&gt; A subclass inherits from a superclass, which inherits from another superclass.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Grandparent:
    def __init__(self, name):
        self.name = name

class Parent(Grandparent):
    def __init__(self, name, age):
        super().__init__(name)
        self.age = age

class Child(Parent):
    def __init__(self, name, age, grade):
        super().__init__(name, age)
        self.grade = grade

child = Child("Alice", 25, "A")
print(child.name)  # Alice
print(child.age)   # 25
print(child.grade) # A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the Child class inherits from the Parent class, which in inherits from the Grandparent class.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hierarchical inheritance:&lt;/strong&gt; Multiple subclasses inherit from a single superclass.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Teacher(Person):
    def __init__(self, name, age, subject):
        super().__init__(name, age)
        self.subject = subject

class Principal(Person):
    def __init__(self, name, age, school_name):
        super().__init__(name, age)
        self.school_name = school_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, both the Teacher and Principal classes inherit from the Person class.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid inheritance:&lt;/strong&gt; A combination of two or more types of inheritance.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class A:
    def method(self):
        print("Method of class A")

class B(A):
    pass

class C(A):
    def method(self):
        print("Method of class C")

class D(B, C):
    pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the D class uses multiple inheritance to inherit from both the B and C classes, which in turn inherit from the A class.&lt;/p&gt;




&lt;h2&gt;
  
  
  Encapsulation:
&lt;/h2&gt;

&lt;p&gt;It is a mechanism that allows us to restrict access to an object's data and methods. When a class member is marked as private, it can only be accessed from within the class. A member can be marked as private by prefixing its name with two underscores.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Book:
    def __init__(self, title, author, price):
        self.title = title
        self.author = author
        self.price = price
        self.__discount = 0.10

book1 = Book('Book 1', 12, 'Author 1', 120)

print(book1.title)     # Book 1
print(book1.author)    # Author 1
print(book1.price)     # 120
print(book1.__discount)# AttributeError: 'Book' object has no attribute '__discount'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We cannot access the '__discount' attribute as it is a private attribute. To access private attributes, we use getter and setter methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Book:
    def __init__(self, title, author, price):
        self.title = title
        self.author = author
        self.price = price
        self.__discount = None

    def set_discount(self, discount):
        self.__discount = discount

    def get_discount(self)
        return self.__discount

book = Book('Book 1', 'Author 1', 200)
book.set_discount(0.10)
print(book.get_discount())    # 0.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Polymorphism:
&lt;/h2&gt;

&lt;p&gt;Polymorphism refers to having many forms. In OOP, it refers to the functions having same names but does different things.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Animal:
    def __init__(self, name):
        self.name = name

    def eat(self):
        print('eating')

class Dog(Animal):
    def show_affection(self):
        print(f'{self.name} wags tail')

class Cat(Animal):
    def show_affection(self):
        print(f'{self.name} purrs')


dog = Dog('Rover')
cat = Cat('Fluffy')

dog.show_affection() # Rover wags tail
cat.show_affection() # Fluffy purrs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Data Abstraction:
&lt;/h2&gt;

&lt;p&gt;Data Abstraction allows us to hide the internal implementations of a function and expose only its functionalities.&lt;br&gt;
To create an abstraction class, first, we need to import the ABC class from abc module. ABC is an acronym for Abstract Base Class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from abc import ABC, abstractmethod

class Vehicle(ABC):
    def __init__(self, name):
        self.name = name

    @abstractmethod
    def info(self):
        pass

vehicle = Vehicle("Honda") # TypeError: Can't instantiate abstract class Car with abstract method info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reason we get the TypeError is we have not implemented the abstract method. Abstract methods are implemented in the child classes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car(Vehicle):
    def info(self):
        print(f"{self.name} information")

car = Car("Honda")
car.info()    # Honda information.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.analyticsvidhya.com/blog/2020/09/object-oriented-programming/"&gt;All About OOPs Concepts in Python Programming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.tutorialspoint.com/object_oriented_python/object_oriented_python_tutorial.pdf"&gt;Object Oriented Python, TutorialsPoint&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/news/object-oriented-programming-in-python/"&gt;Object-Oriented Programming in Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://realpython.com/python3-object-oriented-programming/"&gt;OOP in Python3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Python String Methods</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Wed, 15 Feb 2023 12:53:07 +0000</pubDate>
      <link>https://forem.com/ajith_56/python-string-methods-363l</link>
      <guid>https://forem.com/ajith_56/python-string-methods-363l</guid>
      <description>&lt;p&gt;1.format():&lt;br&gt;
The format() method is used to insert values into a string. It takes a string as a template and replaces any placeholders with the corresponding values.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;str = "I am {} {} method."
print(str.format("learning", "format()"))
#Output: I am learning format() method.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;2.capitalize():&lt;br&gt;
The capitalize() method is used to convert the first character of a string to uppercase, and all other characters to lowercase.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = 'python Language'
print(string.capitalize()) #Output: 'Python language'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above line does not change the original string. To modify the original string, we should assign it to the original string variable.&lt;/p&gt;




&lt;p&gt;3.upper():&lt;br&gt;
The upper() method is used to convert all the characters in a string to uppercase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = 'python'
string = string.upper()
print(string) #Output: 'PYTHON'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use isupper() method on a string to check if all the characters in a string are in upper-case. &lt;/p&gt;




&lt;p&gt;4.lower():&lt;br&gt;
The lower() method is used to convert all the characters in a string to lowercase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = 'Python'
print(string.lower()) #Output: 'python'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use islower() method on a string to check if all the characters in a string are in lower-case.&lt;/p&gt;




&lt;p&gt;5.strip():&lt;br&gt;
The strip() method removes any leading and trailing spaces from a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = '    python    '
print(string.strip()) #Output: 'python'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are also lstrip() and rstrip() methods to strip only the left-end spaces and right-end spaces.&lt;/p&gt;




&lt;p&gt;6.join():&lt;br&gt;
The join() method is used to join all the string values inside a list with a specified separator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list_of_strings = ['abc','def','ghi']
print(''.join(list_of_strings)) #Output: abcdefghi

print(', '.join(list_of_strings)) #Output: abc, def, ghi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;7.isalnum():&lt;br&gt;
The isalnum() method takes a string as an argument and returns True if all the characters in that string are alpanumeric, otherwise returns False.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = 'Python3'
print(string.isalnum()) #True

string = 'Python&amp;amp;3'
print(string.isalnum()) #False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;8.isalpha():&lt;br&gt;
The isalpha() method takes a string as an argument and returns True if all the characters in that string are alpabets, otherwise returns False.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = 'Python'
print(string.isalpha()) #True

string = 'Python3'
print(string.isalpha()) #False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;9.isdigit():&lt;br&gt;
The isdigit() method takes a string as an argument and returns True if all the characters in that string are digits, otherwise returns False.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = '123'
print(string.isdigit()) #True

string = 'python'
print(string.isdigit()) #False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;10.split():&lt;br&gt;
The split() method is used to convert a string to a list of strings by splitting up the string at the specified separator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;languages = 'Python,Java,JavaScript'
print(languages.split(',')) # ['Python', 'Java', 'JavaScript']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;11.startswith():&lt;br&gt;
The startswith() method is used to check whether a string starts with specified prefix or not. It returns True if the string starts with the specified string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = 'Python language'
print(string.startswith('Pyth')) # True

string = 'Python language'
print(string.startswith('pyth    ')) # False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;12.endswith():&lt;br&gt;
The endswith() method is used to check whether a string ends with specified suffix or not. It returns True if the string ends with the specified string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string = 'Python language'
print(string.endswith('uage')) # True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;13.replace():&lt;br&gt;
The replace() method is used to replace every occurrence of matching substring with another string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;line = 'Python is a snake'
line = line.replace('snake', 'language') #Python is a language
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;14.index():&lt;br&gt;
The index() method returns the index of first occurrence of the given substring. If the given substring is not in the string, then it raises an exception.&lt;br&gt;
We can also give start and end index in which we want to find the substring.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;line = 'Hello world'
print(line.index('world')) #6

print(line.index('hello')) #ValueError: substring not found

print(line.index('o', 6, 10)) #7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;15.find():&lt;br&gt;
The find() method is same as index() method. But, it returns -1 when substring is not found.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;line = 'Hello world'
print(line.index('world')) #6

print(line.index('hello')) #-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.programiz.com/python-programming/methods/string" rel="noopener noreferrer"&gt;Python String Methods, Programiz&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/python/python_ref_string.asp" rel="noopener noreferrer"&gt;Python String Methods, W3Schools&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Python List Methods</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Wed, 15 Feb 2023 12:52:46 +0000</pubDate>
      <link>https://forem.com/ajith_56/python-list-methods-39g7</link>
      <guid>https://forem.com/ajith_56/python-list-methods-39g7</guid>
      <description>&lt;p&gt;1.append():&lt;br&gt;
The append() method is used to append a value at the end of an existing list. The value to be appended is passed as an argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;arr = []
arr.append(1)
print(arr) #[1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;2.insert():&lt;br&gt;
The insert() method is used to add an element to a list at the specified position. All the elements from the specified position will be shifted to the right. If the given position is out of range, the element will be appended at the end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[1]
arr.insert(0, 10)
print(arr) #[10, 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;3.extend():&lt;br&gt;
The extend() method takes a list of values as an argument and adds all the values to the existing list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[10, 1]
arr.extend([2, 3, 4])
print(arr) #[10, 1, 2, 3, 4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;4.remove():&lt;br&gt;
The remove() method removes the given element from the list. If there are duplicate elements, the first occurrence will be removed, and if the given element is not in the list, exception will be raised.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) [10, 1, 2, 3, 4]
arr.remove(10)
print(arr) [1, 2, 3, 4]
arr.remove(12) #ValueError: list.remove(x): x not in list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;5.pop():&lt;br&gt;
The pop() method is used to remove an element at a specified index from the list. If the index position is not given, last element will be removed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[1, 2, 3, 4]
arr.pop(2)
print(arr) #[1, 2, 4]
arr.pop()
print(arr) #[1, 2]
arr.pop(4) #IndexError: pop index out of range
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;6.index():&lt;br&gt;
The index() method takes a value as an argument and returns the index of first occurrence  position of that value. If the value is not in the list, an exception will be raised.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[1, 2]
print(arr.index(2)) #1
print(arr.index(3)) #ValueError: list.index(x): x not in list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;7.count():&lt;br&gt;
The count() method takes a value as an argument, searches the value in the list and returns the number of times the value has repeated in the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[1, 2]
print(arr.count(2)) #1
arr.extend([2, 3, 4, 5])
print(arr.count(2)) #2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;8.reverse():&lt;br&gt;
This method reverses the list and returns the reversed list as an output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[1, 2, 2, 3, 4, 5]
arr.reverse()
print(arr) #[5, 4, 3, 2, 2, 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;9.sort():&lt;br&gt;
This method sorts the list list in-place in ascending or descending order. By default, this method sorts the list in ascending order. To sort the list in the descending order we should set reverse to True in the argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[5, 4, 3, 2, 2, 1]
arr.sort()
print(arr) #[1, 2, 2, 3, 4, 5]
arr.sort(reverse=True)
print(arr) #[5, 4, 3, 2, 2, 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;10.copy():&lt;br&gt;
This methods returns a copy of the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[5, 4, 3, 2, 2, 1]
arr2 = arr.copy()
print(arr2) #[5, 4, 3, 2, 2, 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;11.clear():&lt;br&gt;
This method is used to remove all the values inside a list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(arr) #[5, 4, 3, 2, 2, 1]
arr.clear()
print(arr) #[]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/python/python_ref_list.asp" rel="noopener noreferrer"&gt;Python List/Array Methods, W3Schools.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.programiz.com/python-programming/methods/list" rel="noopener noreferrer"&gt;Python List Methods, Programiz.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Introduction to Basic Linux Commands</title>
      <dc:creator>AJITH D R</dc:creator>
      <pubDate>Thu, 02 Feb 2023 04:27:24 +0000</pubDate>
      <link>https://forem.com/ajith_56/introduction-to-basic-linux-commands-2o7p</link>
      <guid>https://forem.com/ajith_56/introduction-to-basic-linux-commands-2o7p</guid>
      <description>&lt;p&gt;In this post, I will be sharing some basic information about Linux commands, which are essential tool to interact with the Linux operating system.&lt;/p&gt;

&lt;p&gt;As you may know, Linux is an open-source operating system based on Unix. One of the primary ways to interact with Linux is through the terminal, which is a command-line interface.&lt;/p&gt;

&lt;p&gt;You can perform various tasks in the terminal using commands. Here I will be explaining 5 commands:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;mkdir&lt;/li&gt;
&lt;li&gt;cd&lt;/li&gt;
&lt;li&gt;mv&lt;/li&gt;
&lt;li&gt;cp&lt;/li&gt;
&lt;li&gt;man&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  mkdir(make directory)
&lt;/h3&gt;

&lt;p&gt;mkdir is a command in Unix-based systems used to create a new directory.&lt;br&gt;
Examples of using the &lt;strong&gt;mkdir&lt;/strong&gt; command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To create a new directory called &lt;em&gt;newdir&lt;/em&gt; in the current directory:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir newdir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;To create a new directory called &lt;em&gt;folder&lt;/em&gt; inside the desktop directory:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir ~/Desktop/folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;If you want to create a directory along with its parent directories in your home directory in one go:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir -p newfolder/myFolder/private
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will create the &lt;em&gt;private&lt;/em&gt; directory, and any necessary parent directories. The -p option allows us to create a directory hierarchy,creating any necessary parent directories along the way.&lt;/p&gt;


&lt;h3&gt;
  
  
  cd (change directory)
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;cd&lt;/strong&gt; is used to navigate the file system and change the current working directory.&lt;br&gt;
Examples of using cd command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you want to go to your home directory:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;or you can just type cd and it will take you to your home directory.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you are in your Desktop directory and you want to go to the parent directory of your Desktop directory:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The below command will take you to the specified directory.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you want to go to the root directory of the file system:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you are in the directory /home/user/documents and you run the command cd /usr/bin, you can use the cd - command to go back to the previous directory, which is /home/user/documents.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;Note that using cd - will only take you to the most recently visited directory. If you have navigated through multiple directories and want to return to an earlier directory, you will need to use cd in combination with the path to that directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There are other flags to use with cd command

&lt;ul&gt;
&lt;li&gt;cd . : It does nothing but stay in your current working directory.&lt;/li&gt;
&lt;li&gt;cd ~ : It will take you to your home directory.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  mv (move or rename)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The mv command is used to move or rename files or directories in your system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples of using mv command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Moving a file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv file.txt /path/to/destination/directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This moves the file file.txt from its current location to the directory at /path/to/destination/directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Renaming a file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv file.txt file_new.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This renames the file file.txt to file_new.txt in the same directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Moving multiple files:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv file1.txt file2.txt /path/to/destination/directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This moves the files file1.txt and file2.txt from their current location to the directory at /path/to/destination/directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Moving a directory:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv directory_name /path/to/destination/directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This moves the directory directory_name and its contents to the directory at /path/to/destination/directory.&lt;/p&gt;




&lt;h3&gt;
  
  
  cp(copy)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The cp command is used to copy files and directories. Here are a few examples to illustrate how to use the cp command along with some flags:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Basic copy:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp file.txt /path/to/destination/directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This copies the file file.txt from its current location to the directory at /path/to/destination/directory&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy directory recursively:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp -R directory_name /path/to/destination/directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This copies the directory directory_name and its contents recursively to the directory at /path/to/destination/directory&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Overwrite existing files:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp -f file.txt /path/to/destination/directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This copies the file file.txt to the directory at /path/to/destination/directory and overwrites existing files in the destination directory if any.&lt;/p&gt;




&lt;h3&gt;
  
  
  man(manual)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It would be difficult to remember all the commands and its flags and options, especially if you are new to linux.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you ever want to know all the information related a particular command, you can use &lt;strong&gt;man&lt;/strong&gt; command.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The man command in Linux is short for manual and is used to display the manual pages of the specified command. * The manual pages provide a detailed description of the command, including its syntax, options, and usage examples.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All you have to do is type man and which command's details you want to know.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;






&lt;p&gt;That is it for this post. I covered how to create a folder/directory, change to a directory, rename or move files/directories, copy files into directory and lastly if you ever stuck on a command make use of man command.&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>help</category>
      <category>discuss</category>
      <category>networking</category>
    </item>
  </channel>
</rss>
