<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ankit Dagar</title>
    <description>The latest articles on DEV Community by Ankit Dagar (@ankit_dagar).</description>
    <link>https://dev.to/ankit_dagar</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%2F1079642%2Fd4e5b4ff-a6fa-4847-98fb-13ecdeabb2b8.png</url>
      <title>DEV Community: Ankit Dagar</title>
      <link>https://dev.to/ankit_dagar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ankit_dagar"/>
    <language>en</language>
    <item>
      <title>Testing</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Tue, 11 Jul 2023 12:01:02 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/testing-231h</link>
      <guid>https://dev.to/ankit_dagar/testing-231h</guid>
      <description>&lt;p&gt;Testing in development refers to the practice of conducting various testing activities throughout the software development lifecycle (SDLC) to ensure the quality, reliability, and functionality of the software being developed. It involves systematically verifying and validating the software against defined requirements, specifications, and user expectations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Manual Testing
&lt;/h2&gt;

&lt;p&gt;Manual testing refers to the process of manually executing test cases and verifying the behavior and functionality of a software application without the use of automated testing tools or scripts. It involves human testers who perform various actions on the application, simulating real-world user interactions to identify defects, errors, and usability issues.&lt;/p&gt;

&lt;p&gt;In manual testing, testers carefully execute test cases step by step, following predefined test procedures and documenting the results. They validate the software against specified requirements, user expectations, and industry standards. Manual testing can be performed at various levels, including unit testing, integration testing, system testing, and acceptance testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  The key aspects of manual testing include:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; Test Planning: Defining the testing objectives, scope, and strategies.&lt;/li&gt;
&lt;li&gt; Test Case Design: Creating detailed test cases that cover various functionalities and scenarios of the software.&lt;/li&gt;
&lt;li&gt; Test Execution: Running the test cases, interacting with the application, and observing its behavior.&lt;/li&gt;
&lt;li&gt; Defect Reporting: Documenting any discrepancies or issues encountered during testing, including steps to reproduce them.&lt;/li&gt;
&lt;li&gt; Test Result Analysis: Reviewing test results, comparing actual results with expected results, and analyzing the overall test coverage.&lt;/li&gt;
&lt;li&gt; Regression Testing: Repeating tests on modified or newly added features to ensure that existing functionalities are not affected.&lt;/li&gt;
&lt;li&gt; Test Closure: Preparing test closure reports, analyzing lessons learned, and providing feedback for process improvement.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Manual testing advantages are:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Flexibility to adapt to changing requirements and dynamic environments.&lt;/li&gt;
&lt;li&gt;  Ability to identify visual, usability, and user experience issues.&lt;/li&gt;
&lt;li&gt;  Early detection of defects that may have been missed by automated tests.&lt;/li&gt;
&lt;li&gt;  Exploration of edge cases and real-world scenarios that are difficult to automate.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Manual testing disadvantages are:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Time-consuming, especially for large and complex applications.&lt;/li&gt;
&lt;li&gt;  Prone to human error, as manual testers can make mistakes during test execution.&lt;/li&gt;
&lt;li&gt;  Limited scalability, as it can be challenging to execute the same test cases repeatedly and consistently.&lt;/li&gt;
&lt;li&gt;  Not suitable for performance testing and load testing, which require simulating a large number of users.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Automation Testing
&lt;/h2&gt;

&lt;p&gt;Automation testing refers to the use of software tools and scripts to automate the execution of test cases and compare the actual results with expected outcomes. It involves the creation and execution of test scripts that simulate user interactions and verify the functionality of software applications.&lt;/p&gt;

&lt;p&gt;In automation testing, specialized testing tools and frameworks are used to automate repetitive and manual testing tasks, reducing the effort and time required for testing. The scripts can be created using programming languages or specific automation tools that provide a user-friendly interface for test script development.&lt;/p&gt;

&lt;h3&gt;
  
  
  The key aspects of automation testing include:
&lt;/h3&gt;

&lt;p&gt;Test Script Creation: Test scripts are created to simulate user actions, such as clicking buttons, entering data, and navigating through the application. These scripts outline the steps to be executed during testing.&lt;/p&gt;

&lt;p&gt;Test Environment Setup: The necessary test environment, including hardware, software, and test data, is prepared to execute the automated tests. This may involve configuring test servers, databases, and other dependencies.&lt;/p&gt;

&lt;p&gt;Test Execution: The automated test scripts are executed by the testing tool or framework. The tool interacts with the application, performs the specified actions, and compares the actual results with expected results.&lt;/p&gt;

&lt;p&gt;Test Reporting: Automation testing tools generate detailed test reports that provide information on test execution status, test coverage, and any failures or errors encountered during the testing process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Automation Testing:
&lt;/h3&gt;

&lt;p&gt;Faster Test Execution: Automated tests can be executed significantly faster than manual tests, allowing for quicker feedback on the software's behavior.&lt;br&gt;
Improved Accuracy: Automation eliminates the risk of human errors and ensures consistent test execution, reducing the chances of overlooking defects.&lt;br&gt;
Reusability: Test scripts can be reused for regression testing, allowing for efficient testing of repeated test scenarios.&lt;br&gt;
Increased Test Coverage: Automation enables the execution of a large number of test cases, expanding test coverage and increasing the likelihood of identifying defects.&lt;/p&gt;

&lt;p&gt;However, it's important to note that automation testing also has its limitations. It may not be suitable for testing certain aspects like visual and usability aspects that require human judgment. Automation testing also requires an upfront investment in terms of time and resources for creating and maintaining the automation framework and scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Manual Testing vs Automation Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Manual Testing:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; Manual testing involves the process of manually executing test cases, where human testers interact with the software application to validate its functionality, usability, and performance.&lt;/p&gt;

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

&lt;p&gt;Flexibility to adapt to changing requirements and dynamic environments.&lt;br&gt;
Effective in identifying visual, usability, and user experience issues.&lt;br&gt;
Early detection of defects that may have been missed by automated tests.&lt;br&gt;
Exploration of edge cases and real-world scenarios that are difficult to automate.&lt;/p&gt;

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

&lt;p&gt;Time-consuming, especially for large and complex applications.&lt;br&gt;
Prone to human error, as manual testers can make mistakes during test execution.&lt;br&gt;
Limited scalability, as executing the same test cases repeatedly and consistently can be challenging.&lt;br&gt;
Not suitable for performance testing and load testing, which require simulating a large number of users.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automation Testing:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; Automation testing involves the use of specialized tools and scripts to automate the execution of test cases. These tools simulate user actions, interact with the software, and compare actual results with expected outcomes.&lt;/p&gt;

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

&lt;p&gt;Faster test execution, allowing for quicker feedback on the software's behavior.&lt;br&gt;
Improved accuracy and consistency in test execution.&lt;br&gt;
Reusability of test scripts for regression testing, ensuring efficient testing of repeated test scenarios.&lt;br&gt;
Increased test coverage by executing a large number of test cases.&lt;/p&gt;

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

&lt;p&gt;Upfront investment in creating and maintaining the automation framework and scripts.&lt;br&gt;
Limited effectiveness in testing visual aspects, usability, and user experience.&lt;br&gt;
Requires technical expertise and knowledge of automation tools.&lt;br&gt;
Certain testing scenarios may be challenging to automate, leading to a need for manual intervention.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;br&gt;
Manual testing is suitable for exploratory testing, usability testing, and scenarios where human judgment is crucial.&lt;br&gt;
Automation testing is beneficial for repetitive tests, regression testing, performance testing, and cases where a large number of test cases need to be executed.&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Asynchronous-JavaScript</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Thu, 01 Jun 2023 10:38:49 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/asynchronous-javascript-18mk</link>
      <guid>https://dev.to/ankit_dagar/asynchronous-javascript-18mk</guid>
      <description>&lt;h2&gt;
  
  
  1. Callbacks :
&lt;/h2&gt;

&lt;p&gt;Callbacks are a fundamental concept in JavaScript that allow for asynchronous programming and handling of events. A callback is simply a function that is passed as an argument to another function and is invoked or called at a later time, often when a certain event or asynchronous operation completes.&lt;/p&gt;

&lt;p&gt;The primary purpose of using callbacks is to ensure that certain code is executed only when a particular task is finished or an event occurs. This is especially useful in situations where the result of an operation is not immediately available or when the order of execution needs to be controlled.&lt;/p&gt;

&lt;p&gt;Here's an example to illustrate the usage of callbacks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function fetchData(callback) {
  // Simulating an asynchronous operation
  setTimeout(() =&amp;gt; {
    const data = { message: 'Data successfully fetched' };
    callback(data); // Invoke the callback function with the fetched data
  }, 2000);
}

function processData(data) {
  console.log('Processing data:', data.message);
}

fetchData(processData); // Pass processData function as a callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, we have a &lt;code&gt;fetchData()&lt;/code&gt; function that simulates an asynchronous operation, such as fetching data from a server. It takes a callback function as an argument. Inside &lt;code&gt;fetchData()&lt;/code&gt;, we use &lt;code&gt;setTimeout()&lt;/code&gt; to simulate a delay of 2 seconds before the data is fetched.&lt;/p&gt;

&lt;p&gt;Once the data is fetched, we invoke the callback function passed to &lt;code&gt;fetchData()&lt;/code&gt; and provide the fetched data as an argument. In this case, the callback function is &lt;code&gt;processData()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;fetchData()&lt;/code&gt; is called, it starts the asynchronous operation and registers the &lt;code&gt;processData()&lt;/code&gt; function as the callback. After 2 seconds, the fetched data is passed to &lt;code&gt;processData()&lt;/code&gt;, and it executes the code within its body, logging the message "Processing data: Data successfully fetched" to the console.&lt;/p&gt;

&lt;p&gt;Callbacks are powerful because they allow us to control the flow of execution in asynchronous scenarios and perform tasks based on the completion of asynchronous operations or events. They are widely used in JavaScript for handling events, making AJAX requests, working with timers, and many other asynchronous operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Promises :
&lt;/h2&gt;

&lt;p&gt;Promises are a built-in feature in JavaScript that provide a more structured and intuitive way to handle asynchronous operations. They are objects representing the eventual completion (or failure) of an asynchronous operation and allow you to handle the result or error using a chain of methods.&lt;/p&gt;

&lt;p&gt;Promises have three states:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Pending: The initial state when a promise is created. It represents that the asynchronous operation is still ongoing, and the promise is neither fulfilled nor rejected.&lt;/li&gt;
&lt;li&gt; Fulfilled: The state when the asynchronous operation is successfully completed, and the promise is fulfilled. At this point, the promise holds a value or result.&lt;/li&gt;
&lt;li&gt; Rejected: The state when the asynchronous operation encounters an error or fails. The promise is rejected and holds a reason or error message.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's an example of using promises:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function fetchData() {
  return new Promise((resolve, reject) =&amp;gt; {
    // Simulating an asynchronous operation
    setTimeout(() =&amp;gt; {
      const data = { message: 'Data successfully fetched' };
      resolve(data); // Resolve the promise with the fetched data
    }, 2000);
  });
}

function processData(data) {
  console.log('Processing data:', data.message);
}

fetchData()
  .then(processData) // Process the fetched data
  .catch(error =&amp;gt; {
    console.error('Error:', error);
  }); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, we have a &lt;code&gt;fetchData()&lt;/code&gt; function that returns a promise. Inside the promise's executor function, we simulate an asynchronous operation using &lt;code&gt;setTimeout()&lt;/code&gt;. After 2 seconds, the promise is fulfilled by calling &lt;code&gt;resolve()&lt;/code&gt; and passing the fetched data.&lt;/p&gt;

&lt;p&gt;We can use the &lt;code&gt;then()&lt;/code&gt; method on the promise to specify the callback function that should be executed when the promise is fulfilled. In this case, we pass &lt;code&gt;processData&lt;/code&gt; as the callback function. The &lt;code&gt;then()&lt;/code&gt; method returns a new promise, allowing for method chaining.&lt;/p&gt;

&lt;p&gt;If an error occurs during the asynchronous operation, we can handle it using the &lt;code&gt;catch()&lt;/code&gt; method. The &lt;code&gt;catch()&lt;/code&gt; method takes a callback function that is executed when the promise is rejected, allowing us to handle any errors that occurred during the execution.&lt;/p&gt;

&lt;p&gt;Promises provide a more structured approach to handling asynchronous operations compared to callbacks. They simplify error handling, allow for better code organization, and support chaining multiple asynchronous operations together. Promises have become a standard way of handling asynchronous code and are widely supported in modern JavaScript environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Code Control :
&lt;/h2&gt;

&lt;p&gt;Code control refers to the ability to manage and control the flow of execution in a program. In JavaScript, there are several mechanisms and constructs that allow for code control, including conditional statements, loops, and error handling.&lt;/p&gt;

&lt;p&gt;1.Conditional Statements:&lt;/p&gt;

&lt;p&gt;Conditional statements, such as &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;else if&lt;/code&gt;, and &lt;code&gt;else&lt;/code&gt;, enable you to control the execution of code based on specified conditions.&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;if (condition) {
  // Code to execute if the condition is true
} else if (anotherCondition) {
  // Code to execute if the anotherCondition is true
} else {
  // Code to execute if none of the conditions are true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Loops:&lt;/p&gt;

&lt;p&gt;Loops allow you to repeatedly execute a block of code until a certain condition is met.&lt;br&gt;
Common loop constructs in JavaScript are &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, and &lt;code&gt;do...while&lt;/code&gt;.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// for loop
for (let i = 0; i &amp;lt; 5; i++) {
  // Code to execute in each iteration
}

// while loop
while (condition) {
  // Code to execute as long as the condition is true
}

// do...while loop
do {
  // Code to execute at least once, then repeat as long as the condition is true
} while (condition);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Error Handling:&lt;/p&gt;

&lt;p&gt;Error handling allows you to catch and handle exceptions or errors that occur during program execution.&lt;br&gt;
The &lt;code&gt;try...catch&lt;/code&gt; statement is used to surround a block of code that may potentially throw an exception, and allows for handling of the error.&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;try {
  // Code that might throw an exception
} catch (error) {
  // Code to handle the error
} finally {
  // Code that will execute regardless of whether an error occurred or not
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Control Flow:&lt;/p&gt;

&lt;p&gt;Control flow refers to the order in which statements and code blocks are executed.&lt;br&gt;
Control flow can be influenced using conditional statements, loops, and control flow keywords like &lt;code&gt;break&lt;/code&gt;, &lt;code&gt;continue&lt;/code&gt;, and &lt;code&gt;return&lt;/code&gt;.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; // break statement
for (let i = 0; i &amp;lt; 5; i++) {
  if (i === 3) {
    break; // Exit the loop when i is 3
  }
  console.log(i);
}

// continue statement
for (let i = 0; i &amp;lt; 5; i++) {
  if (i === 3) {
    continue; // Skip the rest of the loop body when i is 3
  }
  console.log(i);
}

// return statement
function calculateSum(a, b) {
  return a + b; // Return the sum of a and b and exit the function.
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By utilizing these code control mechanisms, you can determine the execution path of your program, handle errors gracefully, and repeat or skip certain sections of code based on conditions. Understanding and effectively utilizing code control constructs is essential for writing structured and efficient JavaScript code.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>JavaScript</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Tue, 30 May 2023 12:41:23 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/javascript-56e6</link>
      <guid>https://dev.to/ankit_dagar/javascript-56e6</guid>
      <description>&lt;h2&gt;
  
  
  1.Loops :
&lt;/h2&gt;

&lt;p&gt;In JavaScript, there are several types of loops that you can use to repeat a block of code multiple times. Here are the main types of loops in JavaScript:&lt;br&gt;
1.&lt;strong&gt;for loop&lt;/strong&gt;: The &lt;code&gt;for&lt;/code&gt; loop is a widely used loop that allows you to repeat a block of code for a specified number of times. It consists of an initialization, a condition, an increment or decrement statement, and the code block to be executed.&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;for (initialization; condition; increment/decrement) {
  // code to be executed
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&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;for (let i = 0; i &amp;lt; 5; i++) {
  console.log(i);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;while loop&lt;/strong&gt;: The &lt;code&gt;while&lt;/code&gt; loop repeats a block of code as long as a specified condition is true. It only has a condition, and the code block is executed repeatedly until the condition becomes false.&lt;br&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;while (condition) {
  // code to be executed
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&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;let i = 0;
while (i &amp;lt; 5) {
  console.log(i);
  i++;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.&lt;strong&gt;for...in loop&lt;/strong&gt;: The &lt;code&gt;for...in&lt;/code&gt; loop is used to iterate over the properties of an object. It allows you to access each property of an object and perform some action.&lt;br&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;for (variable in object) {
  // code to be executed
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&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;const person = {
  name: 'John',
  age: 30,
  city: 'New York',
};

for (let key in person) {
  console.log(key + ': ' + person[key]);
}

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

&lt;/div&gt;



&lt;p&gt;4.&lt;strong&gt;for...of loop&lt;/strong&gt;: The &lt;code&gt;for...of&lt;/code&gt; loop was introduced in ES6 and is used to iterate over iterable objects, such as arrays, strings, and NodeLists. It allows you to access each element of the iterable object.&lt;br&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;for (variable of iterable) {
  // code to be executed
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&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;const colors = ['red', 'green', 'blue'];

for (let color of colors) {
  console.log(color);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.&lt;strong&gt;forEach loop&lt;/strong&gt;: It is a method available on arrays that allows you to iterate over each element of the array and perform a specified action or function on each element. It provides a more concise and expressive way to iterate through arrays compared to traditional &lt;code&gt;for&lt;/code&gt; or &lt;code&gt;while&lt;/code&gt; loops.&lt;br&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;array.forEach(function(currentValue, index, array) {
  // code to be executed on each element
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&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;const numbers = [1, 2, 3, 4, 5];

numbers.forEach(function(number) {
  console.log(number);
});

//Output:
1
2
3
4
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2.Mutable &amp;amp; immutable methods (in strings and in arrays) :
&lt;/h2&gt;

&lt;p&gt;In JavaScript, objects can have both mutable and immutable methods. Let's break down what each of these means:  &lt;/p&gt;

&lt;h3&gt;
  
  
  Mutable methods:
&lt;/h3&gt;

&lt;p&gt;Mutable methods are methods that can modify the object they are called on. They directly change the state of the object by modifying its properties or internal data. These methods typically have side effects and may alter the object's content. Some examples of mutable methods in JavaScript are push(), pop(), splice(), and sort() for arrays. When you call these methods, the original array is modified.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Immutable methods:-
&lt;/h3&gt;

&lt;p&gt;mmutable methods, on the other hand, do not modify the object they are called on. Instead, they return a new object or value that reflects the desired change, leaving the original object unchanged. Immutable methods are non-destructive and are often used in functional programming paradigms. Examples of immutable methods in JavaScript include map(), filter(), and concat() for arrays.  &lt;/p&gt;

&lt;p&gt;Here are some examples of mutable and immutable methods for strings and arrays in JavaScript:  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mutable String Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;concat()&lt;/code&gt;: Joins two or more strings and returns a new string.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toUpperCase()&lt;/code&gt;: Converts the string to uppercase in place.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toLowerCase()&lt;/code&gt;: Converts the string to lowercase in place.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;slice()&lt;/code&gt;: Extracts a portion of the string and returns a new string.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Immutable String Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;toUpperCase()&lt;/code&gt;: Returns a new string with the uppercase conversion.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toLowerCase()&lt;/code&gt;: Returns a new string with the lowercase conversion.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;slice()&lt;/code&gt;: Returns a new string with a portion of the original string.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Mutable Array Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;push()&lt;/code&gt;: Adds one or more elements to the end of an array and returns the new length.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pop()&lt;/code&gt;: Removes the last element from an array and returns that element.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;splice()&lt;/code&gt;: Changes the content of an array by adding or removing elements.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Immutable Array Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;concat()&lt;/code&gt;: Returns a new array that combines two or more arrays.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;slice()&lt;/code&gt;: Returns a new array with a portion of the original array.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;filter()&lt;/code&gt;: Returns a new array with elements that pass a specific condition.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's important to note that the distinction between mutable and immutable methods is not always strict in JavaScript. Some methods may exhibit both mutable and immutable behavior depending on how they are used. Additionally, there are also methods like &lt;code&gt;sort()&lt;/code&gt; and &lt;code&gt;reverse()&lt;/code&gt; that modify the original array in place, making them mutable methods.  &lt;/p&gt;

&lt;h2&gt;
  
  
  3.pass by reference &amp;amp; pass by value :
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the concept of pass by reference and pass by value depends on the type of data being passed as an argument to a function.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pass by Value:&lt;/strong&gt;&lt;br&gt;
When you pass a primitive data type (such as numbers, strings, or booleans) to a function, it is passed by value. It means that a copy of the value is created and assigned to a new variable within the function. Any changes made to this new variable will not affect the original value outside the function.&lt;/p&gt;

&lt;p&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;function updateValue(value)  
{
value = 42; // Updating the value inside the function  
}
let num = 10;  
updateValue(num);  
console.log(num);  

Output: 10  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;num&lt;/code&gt; variable is passed by value to the &lt;code&gt;updateValue&lt;/code&gt; function. Even though the function assigns a new value of 42 to the &lt;code&gt;value&lt;/code&gt; parameter, it does not affect the original &lt;code&gt;num&lt;/code&gt; variable because it is a copy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pass by Reference:&lt;/strong&gt;&lt;br&gt;
When you pass an object (including arrays and functions) to a function, it is passed by reference. It means that the memory address of the object is passed, rather than creating a copy of the object. Any modifications made to the object inside the function will affect the original object.&lt;/p&gt;

&lt;p&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;function updateArray(array)
{
array.push(4); // Modifying the array inside the function  
}
let numbers = [1, 2, 3];
updateArray(numbers);
console.log(numbers);

Output: [1, 2, 3, 4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;numbers&lt;/code&gt; array is passed by reference to the &lt;code&gt;updateArray&lt;/code&gt; function. When the function pushes the value 4 into the &lt;code&gt;array&lt;/code&gt; parameter, it modifies the original &lt;code&gt;numbers&lt;/code&gt; array as well.  &lt;/p&gt;

&lt;p&gt;It's important to note that even though objects are passed by reference, reassigning the entire object within the function will not affect the original object outside the function. It only affects the local variable referencing that object.&lt;/p&gt;

&lt;p&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;function updateObject(obj)
{
obj = { name: 'John' }; // Reassigning the object inside the function
}
let person = { name: 'Alice' };
updateObject(person);
console.log(person);

Output: { name: 'Alice' }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the &lt;code&gt;obj&lt;/code&gt; parameter inside the function is reassigned to a new object, but it doesn't modify the original &lt;code&gt;person&lt;/code&gt; object. The local &lt;code&gt;obj&lt;/code&gt; variable now points to a different memory location.&lt;/p&gt;

&lt;h2&gt;
  
  
  4.Array methods :
&lt;/h2&gt;

&lt;p&gt;In JavaScript, arrays have several built-in methods that can be used to modify the array directly. These methods are referred to as mutable array methods because they modify the original array rather than creating a new array. Here are some commonly used mutable array methods:  &lt;/p&gt;

&lt;p&gt;1.push: The &lt;code&gt;push&lt;/code&gt; method adds one or more elements to the end of an array.&lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3];
numbers.push(4, 5);
console.log(numbers);

Output: [1, 2, 3, 4, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.pop: The &lt;code&gt;pop&lt;/code&gt; method removes the last element from an array and returns that element.&lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4, 5];
const lastElement = numbers.pop();
console.log(lastElement);
console.log(numbers);

Output: 5  
[1, 2, 3, 4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.shift: The &lt;code&gt;shift&lt;/code&gt; method removes the first element from an array and returns that element. It also shifts all the remaining elements to a lower index.&lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4, 5];
const firstElement = numbers.shift();
console.log(firstElement);
console.log(numbers);

Output: 1
[2, 3, 4, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.unshift: The &lt;code&gt;unshift&lt;/code&gt; method adds one or more elements to the beginning of an array and shifts the existing elements to higher indices.&lt;/p&gt;

&lt;p&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;const numbers = [2, 3, 4, 5];
numbers.unshift(1);
console.log(numbers);

Output: [1, 2, 3, 4, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.splice: The &lt;code&gt;splice&lt;/code&gt; method can be used to add, remove, or replace elements within an array. It modifies the original array and returns the removed elements.&lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 5, 6];
numbers.splice(2, 0, 3, 4); // Inserts 3 and 4 at index 2
console.log(numbers);
numbers.splice(3, 2); // Removes 2 elements starting from index 3
console.log(numbers);

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

&lt;/div&gt;



&lt;p&gt;These mutable array methods provide convenient ways to modify arrays directly. However, it's important to be cautious when using them as they can alter the original array, potentially affecting other parts of your code.&lt;/p&gt;

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

&lt;p&gt;1.push: Adds one or more elements to the end of an array and returns the new length of the array.&lt;/p&gt;

&lt;p&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;let array = [1, 2, 3];
array.push(4);
console.log(array);

Output: [1, 2, 3, 4]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.pop: Removes the last element from an array and returns that element.  &lt;/p&gt;

&lt;p&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;let array = [1, 2, 3];  
let lastElement = array.pop();  
console.log(lastElement); // Output: 3  
console.log(array);  

Output: [1, 2]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.concat: Concatenates two or more arrays and returns a new array.  &lt;/p&gt;

&lt;p&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;let arr1 = [1, 2, 3];  
let arr2 = [4, 5];  
let newArr = arr1.concat(arr2);  
console.log(newArr);  

Output: [1, 2, 3, 4, 5]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Slice :-  &lt;/p&gt;

&lt;p&gt;(i) slice using an array : Extracts a portion of an array and returns a new array without modifying the original array.  &lt;/p&gt;

&lt;p&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;let arr = [1, 2, 3, 4, 5];  
let newArr = arr.slice(2);  
console.log(newArr);  

Output: [3, 4, 5]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(ii) slice using an string : Extracts a portion of a string and returns a new string without modifying the original string.  &lt;/p&gt;

&lt;p&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;let str = 'Hello World';  
let newStr = str.slice(6);  
console.log(newStr);  

Output: 'World'  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.splice: This method is mutable. Changes the contents of an array by removing, replacing, or adding elements. It modifies the original array  &lt;/p&gt;

&lt;p&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;let arr = [1, 2, 3, 4, 5];  
arr.splice(2, 1);  
console.log(arr);  

Output: [1, 2, 4, 5]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6.join: This method is immutable. It joins all elements of an array into a string, using a specified separator, and returns the resulting string. The original array remains unchanged.  &lt;/p&gt;

&lt;p&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;const fruits = ['apple', 'banana', 'orange'];  
const joinedString = fruits.join(', ');  
console.log(joinedString); // Output: 'apple, banana, orange'  
console.log(fruits);  

Output: ['apple', 'banana', 'orange']  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, &lt;code&gt;join&lt;/code&gt; returns a new string with all the elements of the &lt;code&gt;fruits&lt;/code&gt; array joined by &lt;code&gt;', '&lt;/code&gt;. The original array &lt;code&gt;fruits&lt;/code&gt; is not modified.&lt;/p&gt;

&lt;p&gt;7.flat:&lt;br&gt;
The flat() method is an array method in JavaScript that is used to flatten a nested array by concatenating its subarrays into a new array. It returns a new array with all the elements of the original array and any subarrays concatenated together into a single level.&lt;/p&gt;

&lt;p&gt;The flat() method can be invoked on an array and accepts an optional parameter depth, which determines the depth of flattening. By default, depth is set to 1, meaning only the immediate nested arrays are flattened. If a negative value is provided for depth, it will flatten all nested arrays regardless of their depth.&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;const nestedArray = [1, 2, [3, 4], [5, [6, 7]]];

const flattenedArray = nestedArray.flat();

console.log(flattenedArray);
// Output: [1, 2, 3, 4, 5, [6, 7]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;1.find: The &lt;code&gt;find&lt;/code&gt; method is used to find the first element in an array that satisfies a given condition. It takes a callback function as an argument and returns the first element for which the callback function returns a truthy value. If no element is found, it returns &lt;code&gt;undefined&lt;/code&gt;.  &lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4, 5];  
const found = numbers.find((element) =&amp;gt; element &amp;gt; 3);  
console.log(found);  

Output: 4  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.indexOf: The &lt;code&gt;indexOf&lt;/code&gt; method is used to find the index of the first occurrence of a specified element or value in an array or string. It returns the index of the element if found, and -1 if the element is not present.  &lt;/p&gt;

&lt;p&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;const fruits = ['apple', 'banana', 'orange', 'banana'];  
const index = fruits.indexOf('banana');  
console.log(index);  

Output: 1  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.includes: The &lt;code&gt;includes&lt;/code&gt; method is used to check whether an array or string contains a specific element or value. It returns &lt;code&gt;true&lt;/code&gt; if the element is found, and &lt;code&gt;false&lt;/code&gt; otherwise.  &lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4, 5];  
const includesThree = numbers.includes(3);  
console.log(includesThree);  

Output: true  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.findIndex: The &lt;code&gt;findIndex&lt;/code&gt; method is similar to the &lt;code&gt;find&lt;/code&gt; method, but it returns the index of the first element that satisfies a given condition instead of the element itself. If no element is found, it returns -1.  &lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4, 5];  
const index = numbers.findIndex((element) =&amp;gt; element &amp;gt; 3);  
console.log(index);  

Output: 3  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These methods are commonly used in JavaScript to search for elements or values within arrays or strings based on different conditions.  &lt;/p&gt;

&lt;h3&gt;
  
  
  3.Higher order functions :
&lt;/h3&gt;

&lt;p&gt;Higher-order functions are an important concept in functional programming. They are functions that can take other functions as arguments or return functions as results. In this context, let's explore some common higher-order functions: &lt;code&gt;forEach&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;reduce&lt;/code&gt;, and &lt;code&gt;sort&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;1.forEach: The &lt;code&gt;forEach&lt;/code&gt; function is used to iterate over an array or a collection and apply a function to each element. It doesn't return a new array; instead, it performs an action for each element.  &lt;/p&gt;

&lt;p&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;Const numbers = [1, 2, 3, 4];  
numbers.forEach  
( (num) =&amp;gt;  
{  
console.log(num);  
}  
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.filter: The &lt;code&gt;filter&lt;/code&gt; function creates a new array containing elements from the original array that satisfy a specified condition defined by a filtering function.  &lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4];  
const evenNumbers = numbers.filter((num) =&amp;gt; num % 2 === 0);  
console.log(evenNumbers);  

Output: [2, 4]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.map: The &lt;code&gt;map&lt;/code&gt; function applies a transformation function to each element of an array and returns a new array containing the transformed elements.  &lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4];  
const doubledNumbers = numbers.map((num) =&amp;gt; num * 2);  
console.log(doubledNumbers); // Output: [2, 4, 6, 8]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.reduce: The &lt;code&gt;reduce&lt;/code&gt; function takes an array and reduces it to a single value by applying an accumulator function to each element. The accumulator function takes an accumulated value and the current element and returns a new accumulated value.  &lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4];  
const sum = numbers.reduce((accumulator, num) =&amp;gt; accumulator + num, 0);  
console.log(sum);  

Output: 10  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.sort: The &lt;code&gt;sort&lt;/code&gt; function is used to sort the elements of an array in place. It takes an optional comparison function that defines the sorting order.  &lt;/p&gt;

&lt;p&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;const numbers = [4, 2, 1, 3];  
numbers.sort((a, b) =&amp;gt; a - b);  
console.log(numbers);  

Output: [1, 2, 3, 4]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These higher-order functions provide powerful tools for working with arrays and collections in a functional programming paradigm, making the code concise and expressive.  &lt;/p&gt;

&lt;h3&gt;
  
  
  4.Advanced :
&lt;/h3&gt;

&lt;p&gt;Array methods chaining is a technique where multiple array methods are chained together to perform a sequence of operations on an array. Each method in the chain operates on the result of the previous method, allowing you to perform complex transformations and manipulations on arrays in a concise manner.  &lt;/p&gt;

&lt;p&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;const numbers = [1, 2, 3, 4, 5];  
const result = numbers  
.filter((num) =&amp;gt; num % 2 === 0) // Filter even numbers  
.map((num) =&amp;gt; num * 2)  // Double each number  
.reduce((sum, num) =&amp;gt; sum + num, 0); // Sum all numbers  
console.log(result);  

Output: 18  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example:  &lt;/p&gt;

&lt;p&gt;1.&lt;code&gt;filter&lt;/code&gt; is used to filter out even numbers from the original array.&lt;br&gt;&lt;br&gt;
2.&lt;code&gt;map&lt;/code&gt; is then used to double each filtered number.&lt;br&gt;&lt;br&gt;
3.Finally, &lt;code&gt;reduce&lt;/code&gt; is applied to sum up all the doubled numbers.  &lt;/p&gt;

&lt;p&gt;By chaining these methods together, you can achieve the desired result in a concise and readable way.  &lt;/p&gt;

&lt;p&gt;It's important to note that when using method chaining, the order of methods in the chain matters. Each method operates on the result of the previous method, so you need to consider the desired sequence of operations.  &lt;/p&gt;

&lt;p&gt;Method chaining is a powerful technique that allows you to perform complex array manipulations in a more compact and expressive manner, enhancing code readability and maintainability.&lt;/p&gt;
&lt;h2&gt;
  
  
  5.String methods :
&lt;/h2&gt;

&lt;p&gt;In JavaScript, strings are immutable, which means that once a string is created, it cannot be changed. However, there are string methods that return a modified version of the original string without directly modifying it. Let's take a look at some of the commonly used string methods in JavaScript:  &lt;/p&gt;

&lt;p&gt;1.concat(): This method concatenates two or more strings and returns a new string.  &lt;/p&gt;

&lt;p&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;let str1 = 'Hello';  
let str2 = 'World';  
let result = str1.concat(' ', str2);  
console.log(result);  

Output: "Hello World"  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.toUpperCase(): Converts the string to uppercase and returns a new string.  &lt;/p&gt;

&lt;p&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;const str = "hello, world";  
const newString = str.toUpperCase();  
console.log(newString);  

Output: "HELLO, WORLD"  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.toLowerCase(): Converts the string to lowercase and returns a new string.  &lt;/p&gt;

&lt;p&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;const str = "HELLO, WORLD";  
const newString = str.toLowerCase();  
console.log(newString);  

Output: "hello, world"  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These methods, along with others, allow you to perform various operations on strings without modifying the original string itself.  &lt;/p&gt;

&lt;p&gt;4.slice(): This method returns a new string containing a portion of the original string based on the specified start and end indices.  &lt;/p&gt;

&lt;p&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;let str = 'Hello World';  
let result = str.slice(6, 11);  
console.log(result);  

Output: "World"  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.replace(): This method returns a new string with all occurrences of a specified substring replaced by another substring.  &lt;/p&gt;

&lt;p&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;let str = 'Hello World';  
let result = str.replace('World', 'Universe');  
console.log(result);  

Output: "Hello Universe"  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6.split(): This method splits a string into an array of substrings based on a specified delimiter and returns the array.  &lt;/p&gt;

&lt;p&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 = 'Hello,World';  
let result = str.split(',');  
console.log(result);  

Output: ["Hello", "World"]  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These methods, and many others, allow you to perform various operations on strings while keeping the original string unchanged. Remember that each method returns a new string, so you need to assign the result to a variable if you want to store or use the modified string.&lt;/p&gt;

&lt;h2&gt;
  
  
  6.Object methods &amp;amp; operations :
&lt;/h2&gt;

&lt;p&gt;In JavaScript, objects are one of the fundamental data types and can have properties and methods associated with them. Methods in JavaScript are functions that are defined as properties of an object. They can be invoked or called to perform certain actions or operations on the object or its data.  &lt;/p&gt;

&lt;p&gt;1.Defining an Object:&lt;br&gt;&lt;br&gt;
Objects can be defined using object literals, constructor functions, or ES6 classes.  &lt;/p&gt;

&lt;p&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;const person =  
{  
name: 'John',  
age: 30,  
greet: function()  
    {  
        console.log(`Hello, my name is ${[this.name]}`);  
    }  
};  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Accessing Object Properties:&lt;br&gt;&lt;br&gt;
Object properties can be accessed using dot notation (&lt;code&gt;object.property&lt;/code&gt;) or bracket notation (&lt;code&gt;object['property']&lt;/code&gt;).  &lt;/p&gt;

&lt;p&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;console.log(person['name']);  
console.log(person['age']);  

Output: john  
30  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Defining Object Methods:&lt;br&gt;&lt;br&gt;
Object methods are defined as functions within an object. They can access and modify object properties using the &lt;code&gt;this&lt;/code&gt; keyword.  &lt;/p&gt;

&lt;p&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;const person =  
{  
name: 'John',  
age: 30,  
greet: function()  
    {  
        console.log(`Hello, my name is ${[this.name]}`);  
    },  
increaseAge: function()  
    {  
        this.age++;  
    }  
};  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Invoking Object Methods:&lt;br&gt;&lt;br&gt;
Object methods are invoked by using the dot notation or bracket notation with parentheses.  &lt;/p&gt;

&lt;p&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;person.greet();  
person.increaseAge();  
console.log(person.age);  

Output:  
Hello, my name is John  
31  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.The &lt;code&gt;this&lt;/code&gt; Keyword:&lt;br&gt;&lt;br&gt;
The &lt;code&gt;this&lt;/code&gt; keyword refers to the object that the method belongs to. It allows you to access and modify object properties within the method.  &lt;/p&gt;

&lt;p&gt;6.Shorthand Method Syntax:&lt;br&gt;
ES6 introduced a shorthand syntax for defining object methods using concise method notation.  &lt;/p&gt;

&lt;p&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;const person =  
{  
name: 'John',  
age: 30,  
greet() {  
console.log(`Hello, my name is ${[this.name](http://this.name/)}`);  
},  
increaseAge() {  
this.age++;  
}  
};  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;7.Object Operations:&lt;br&gt;&lt;br&gt;
Object methods can perform various operations on object data, such as manipulating properties, performing calculations, iterating over object properties, or interacting with other objects.  &lt;/p&gt;

&lt;p&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;const calculator =  
{  
    operand1: 0,  
    operand2: 0,  
    add()  
    {  
        return this.operand1 + this.operand2;  
    },  
    multiply()  
    {  
        return this.operand1 * this.operand2;  
    }  
};  
calculator.operand1 = 5;  
calculator.operand2 = 3;  
console.log(calculator.add());  
console.log(calculator.multiply());  

Output:  
8  
15  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are the basic concepts of object methods and operations in JavaScript. Objects provide a powerful way to organize and work with related data and behavior in JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  7.Hoisting :
&lt;/h2&gt;

&lt;p&gt;In JavaScript, hoisting is a mechanism where variable and function declarations are moved to the top of their containing scope during the compilation phase. This means that you can use variables and functions before they are declared in your code. However, it's important to note that only the declarations are hoisted, not the initializations or assignments.  &lt;/p&gt;

&lt;p&gt;There are two types of hoisting in JavaScript: hoisting of variables and hoisting of functions.  &lt;/p&gt;

&lt;p&gt;1.Hoisting of Variables:&lt;br&gt;&lt;br&gt;
When variables are hoisted, the declaration of the variable is moved to the top of the scope, but the assignment or initialization remains in its original place. This means that you can use a variable before it is declared, but its value will be undefined until it is assigned a value.  &lt;/p&gt;

&lt;p&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;console.log(myVariable); // undefined  
var myVariable = 10;  
console.log(myVariable);  

Output :10  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code is actually interpreted as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var myVariable;  // Declaration is hoisted  
console.log(myVariable); // undefined  
myVariable = 10; // Assignment remains in its original place  
console.log(myVariable);  
Output : 10  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Hoisting of Functions:&lt;br&gt;&lt;br&gt;
When functions are hoisted, both the function declaration and its body are moved to the top of the scope. This means that you can call a function before it is declared in your code.  &lt;/p&gt;

&lt;p&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;myFunction();   
function myFunction()  
{  
    console.log("Hello, World!");  
}  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code is actually interpreted as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function myFunction()  
{ // Both declaration and body are hoisted  
        console.log("Hello, World!");  
}  
myFunction();  

output : "Hello, World!"  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's important to be aware of hoisting in JavaScript to understand the behavior of your code. However, it's considered a best practice to declare variables and functions at the beginning of their scope to avoid any confusion or unexpected behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  8.Scopes :
&lt;/h2&gt;

&lt;p&gt;In JavaScript, scopes determine the accessibility and visibility of variables, functions, and objects within your code. Understanding how scopes work is crucial for writing efficient and organized JavaScript programs. There are two main types of scopes in JavaScript: global scope and local scope (also known as function scope).  &lt;/p&gt;

&lt;p&gt;1.Global Scope:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables declared outside of any function are considered to be in the global scope.
&lt;/li&gt;
&lt;li&gt;Global variables can be accessed from any part of your code, including inside functions.
&lt;/li&gt;
&lt;li&gt;When a variable is accessed, JavaScript first checks the local scope, and if the variable is not found, it looks in the global scope.
&lt;/li&gt;
&lt;li&gt;Global variables can be accessed and modified from any part of your code, which can lead to potential issues if not managed properly.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example of a global variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var globalVariable = 10;  
function myFunction()  
{  
    console.log(globalVariable);  // Accessing global variable  
}  
myFunction();  

Output: 10  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Local Scope (Function Scope):  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables declared inside a function are considered to be in the local scope.
&lt;/li&gt;
&lt;li&gt;Local variables are accessible only within the function in which they are declared.
&lt;/li&gt;
&lt;li&gt;Each function has its own separate local scope, and variables with the same name can exist in different function scopes without conflict.
&lt;/li&gt;
&lt;li&gt;Local variables take precedence over global variables with the same name.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example of a local variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function myFunction()  
{  
    var localVariable = 5; // Local variable  
    console.log(localVariable);  
}  

myFunction(); //Output: 5  

console.log(localVariable);  // Error: localVariable is not defined  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Block Scope (Introduced in ES6):  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Starting from ECMAScript 2015 (ES6), JavaScript introduced block scope using the &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; keywords.
&lt;/li&gt;
&lt;li&gt;Variables declared with &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; inside a block (e.g., within loops or conditional statements) are limited to the block scope.
&lt;/li&gt;
&lt;li&gt;Block-scoped variables are not accessible outside the block in which they are defined.
&lt;/li&gt;
&lt;li&gt;Block scope helps prevent variable leakage and provides better control over variable lifespan.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example of block scope:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (true)  
{  
    let blockScopedVariable = 20; // Block-scoped variable  
    console.log(blockScopedVariable);  
}  
console.log(blockScopedVariable); // Error: blockScopedVariable is not defined  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note: Prior to ES6, JavaScript had function scope but not block scope. Block-scoped variables introduced with &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; provide more granular control over variable scoping.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Understanding and utilizing scopes effectively is crucial for writing maintainable and bug-free JavaScript code.&lt;/p&gt;

&lt;h2&gt;
  
  
  9.Clousers :
&lt;/h2&gt;

&lt;p&gt;It is a combination of a function and the lexical environment in which it was declared. It allows a function to access variables from its outer (enclosing) scope, even after the outer function has finished executing. In other words, a closure gives you access to an outer function's scope from an inner function.&lt;/p&gt;

&lt;p&gt;Here's an example to illustrate closures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function outerFunction() {
  const outerVariable = 'I am from outer';

  function innerFunction() {
    console.log(outerVariable); // Accessing outerVariable from the outer scope
  }

  return innerFunction;
}

const inner = outerFunction();
inner(); // Prints: I am from outer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, &lt;code&gt;outerFunction&lt;/code&gt; is the outer function that declares the &lt;code&gt;outerVariable&lt;/code&gt;. The &lt;code&gt;innerFunction&lt;/code&gt; is the inner function defined inside &lt;code&gt;outerFunction&lt;/code&gt;. The &lt;code&gt;innerFunction&lt;/code&gt; has access to the &lt;code&gt;outerVariable&lt;/code&gt; even after &lt;code&gt;outerFunction&lt;/code&gt; has finished executing. This is possible because of the closure.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;outerVariable&lt;/code&gt; is captured by the &lt;code&gt;innerFunction&lt;/code&gt;, forming a closure. When &lt;code&gt;innerFunction&lt;/code&gt; is invoked (&lt;code&gt;inner()&lt;/code&gt;), it can still access and use the &lt;code&gt;outerVariable&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Closures are commonly used to create private variables and encapsulation in JavaScript. By defining variables within an outer function and returning an inner function that can access and modify those variables, you can create a private scope where the variables are not directly accessible from the outside.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function createCounter() {
  let count = 0;

  return {
    increment() {
      count++;
    },
    decrement() {
      count--;
    },
    getCount() {
      return count;
    }
  };
}

const counter = createCounter();
console.log(counter.getCount()); // 0
counter.increment();
counter.increment();
console.log(counter.getCount()); // 2
counter.decrement();
console.log(counter.getCount()); // 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;createCounter&lt;/code&gt; function returns an object with three methods: &lt;code&gt;increment&lt;/code&gt;, &lt;code&gt;decrement&lt;/code&gt;, and &lt;code&gt;getCount&lt;/code&gt;. The &lt;code&gt;count&lt;/code&gt; variable is enclosed within the scope of the &lt;code&gt;createCounter&lt;/code&gt; function and can only be accessed or modified through the methods of the returned object. This creates a private variable that is protected from direct access or modification from outside the object.&lt;/p&gt;

&lt;p&gt;Closures are powerful in JavaScript and provide a way to maintain state and create encapsulated functions with persistent access to their lexical environments. They are widely used in various JavaScript patterns and can be quite useful in functional programming, event handling, and asynchronous operations.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>HTML/CSS</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Wed, 24 May 2023 13:04:46 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/htmlcss-48o5</link>
      <guid>https://dev.to/ankit_dagar/htmlcss-48o5</guid>
      <description>&lt;h2&gt;
  
  
  Box model :
&lt;/h2&gt;

&lt;p&gt;The CSS box model is a fundamental concept in web design and layout that describes how elements are rendered and how their dimensions are calculated. It is used to develop the design and structure of a web page. It can be used as a set of tools to personalize the layout of different components. It consists of several components that determine the overall size and positioning of an element within a web page.  &lt;/p&gt;

&lt;p&gt;The CSS box model consists of four main parts:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Content: It represents the actual content of the element, such as text, images, or other HTML elements. The size of the content area is determined by the width and height properties.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Padding: It is a transparent area surrounding the content and provides space between the content and the border. Padding can be set using the padding property and can have individual values for each side (top, right, bottom, left) or a shorthand notation.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Border: It is a line that surrounds the padding and content areas. Borders can be customized using properties like border-width, border-style, and border-color.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Margin: It is an invisible area outside the border that separates the element from other elements on the page. Margins can be set using the margin property and can also have individual values for each side or a shorthand notation.  &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's an example :&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="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&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;200px&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;100px&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="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&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="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="p"&gt;}&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;body&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;"box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a box&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understanding the CSS box model is crucial for positioning and layout in CSS, as it determines how elements interact with each other and how much space they occupy on a webpage.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Inline versus block elements :
&lt;/h2&gt;

&lt;p&gt;In HTML, elements are categorized into two main types: inline elements and block elements. These categories determine how elements are displayed and how they interact with other elements on a webpage.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Block Elements:
&lt;/li&gt;
&lt;li&gt;Block elements are formatted as blocks and create a new line before and after the element.
&lt;/li&gt;
&lt;li&gt;They take up the full width available by default, unless their width is explicitly set.
&lt;/li&gt;
&lt;li&gt;Examples of block elements include &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;, etc.
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Block elements can contain both block and inline elements.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inline Elements:  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inline elements are formatted inline and do not create a new line before or after the element.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They occupy only the space necessary to render their content and do not affect the layout of surrounding elements.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Examples of inline elements include &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;em&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt;, etc.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inline elements cannot contain block-level elements but can contain other inline elements.  &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's an example to illustrate the difference between block and inline elements:&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="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;  
&lt;span class="nc"&gt;.block&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="no"&gt;lightblue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="nc"&gt;.inline&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="no"&gt;lightgreen&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;body&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;"block"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a block element (div)&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"inline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is an inline element (span)&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"block"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is another block element (p)&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements are block elements, so they appear as separate blocks, each taking up the full width available. The &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; element is an inline element, so it does not create a new line and only occupies the necessary space around its content.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Relative positioning and Absolute positioning :
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Relative Positioning:
Relative positioning refers to positioning an element relative to its normal position within the document flow. When an element is relatively positioned, it can be moved from its original position using CSS properties like top, right, bottom, and left. The element is then positioned based on its original position, and nearby elements still occupy their original space in the document flow.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, consider the following CSS code:&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;.relative-box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="nl"&gt;left&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, the element with the class "relative-box" will be moved 50 pixels down from its normal position and 20 pixels to the right.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Absolute Positioning:
Absolute positioning refers to positioning an element relative to its nearest positioned ancestor or, if there is none, relative to the document's initial containing block (usually the viewport). When an element is absolutely positioned, it is taken out of the normal document flow, and other elements are positioned as if the absolutely positioned element does not exist.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Absolute positioning is typically achieved by specifying CSS properties like top, right, bottom, and left. These properties define the exact position of the element relative to its nearest positioned ancestor.  &lt;/p&gt;

&lt;p&gt;For example:&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;.absolute-box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="nl"&gt;top&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="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&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 case, the element with the class "absolute-box" will be positioned 100 pixels down from its nearest positioned ancestor and 50 pixels from the right edge.  &lt;/p&gt;

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

&lt;p&gt;In CSS, structural classes are classes that are used to target elements based on their position within a structure or hierarchy, rather than their specific attributes or content. These classes are useful for applying styles to specific elements or groups of elements within a structured layout. Here are a few commonly used structural classes:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:first-child:
The &lt;code&gt;:first-child&lt;/code&gt; pseudo-class selects the first child element of its parent container. It matches an element that is the first child among its siblings.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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="nt"&gt;ul&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:first-child&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&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, the first &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element within a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; will have its text color set to red.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:nth-child():
The &lt;code&gt;:nth-child()&lt;/code&gt; pseudo-class allows you to select elements based on their position among their siblings using a formula. It takes an argument in the form of an expression, such as &lt;code&gt;n&lt;/code&gt;, &lt;code&gt;2n&lt;/code&gt;, &lt;code&gt;3n+1&lt;/code&gt;, etc.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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="nt"&gt;ul&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;odd&lt;/span&gt;&lt;span class="o"&gt;)&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="n"&gt;lightgray&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;This CSS rule applies a light gray background to all odd-numbered &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; elements within a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:last-child:
The &lt;code&gt;:last-child&lt;/code&gt; pseudo-class selects the last child element of its parent container.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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="nt"&gt;ul&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:last-child&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&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, the last &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element within a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; will have its font-weight set to bold.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:only-child:
The &lt;code&gt;:only-child&lt;/code&gt; pseudo-class matches elements that are the only child of their parent container.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="nd"&gt;:only-child&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;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;blue&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;Here, any &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element that is the only child within a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; will have a blue border.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:nth-last-child():
The &lt;code&gt;:nth-last-child()&lt;/code&gt; pseudo-class selects elements based on their position counted from the end of the parent container.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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="nt"&gt;ul&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:nth-last-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;2&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;underline&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;This rule underlines the second-to-last &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element within a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:first-of-type:
The &lt;code&gt;:first-of-type&lt;/code&gt; pseudo-class matches the first element of its type among its siblings.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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="nt"&gt;h2&lt;/span&gt;&lt;span class="nd"&gt;:first-of-type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&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;Here, the first &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; element within its parent container will have its text color set to green.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:nth-of-type():
The &lt;code&gt;:nth-of-type()&lt;/code&gt; pseudo-class selects elements based on their position among their siblings of the same type.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex:&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="nt"&gt;ul&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:nth-of-type&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;3&lt;/span&gt;&lt;span class="nt"&gt;n&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="err"&gt;2&lt;/span&gt;&lt;span class="o"&gt;)&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="no"&gt;lightblue&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, every third &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element (starting from the second one) within a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; will have a light blue background.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:last-of-type:
The &lt;code&gt;:last-of-type&lt;/code&gt; pseudo-class selects the last element of its type among its siblings.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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="nt"&gt;p&lt;/span&gt;&lt;span class="nd"&gt;:last-of-type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;font-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;italic&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;Here, the last &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element within its parent container will have its font-style set to italic.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:nth-last-of-type():
The &lt;code&gt;:nth-last-of-type()&lt;/code&gt; pseudo-class selects elements based on their position counted from the end among their siblings of the same type.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="nd"&gt;:nth-last-of-type&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;odd&lt;/span&gt;&lt;span class="o"&gt;)&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="no"&gt;yellow&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;This CSS rule applies a yellow background to all odd-numbered &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements within a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;.  &lt;/p&gt;

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

&lt;p&gt;In CSS, you can define and apply styling classes to elements using the class selector. Styling classes are reusable sets of CSS rules that can be applied to multiple elements on a webpage. Here's how you define and use styling classes in CSS:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Defining a Class:
To define a class, you prefix the class name with a dot (.) and specify the desired CSS rules within curly braces {}.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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;.my-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16px&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 define a class called "my-class" with the color set to red and font size set to 16 pixels.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Applying a Class:
To apply a class to an HTML element, you use the &lt;code&gt;class&lt;/code&gt; attribute and set it to the name of the class you want to apply.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"my-class"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This paragraph has the "my-class" styling applied.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the "my-class" styling class is applied to the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Multiple Classes:
You can apply multiple classes to an element by separating the class names with spaces within the &lt;code&gt;class&lt;/code&gt; attribute.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"my-class another-class"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This paragraph has both "my-class" and "another-class" styling applied.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, both "my-class" and "another-class" styling classes are applied to the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Specificity and Cascading:
When applying multiple classes or combining them with other CSS selectors, the specificity rules and cascading nature of CSS determine which styles take precedence. The order of the classes or their placement in the CSS file can also affect the final styles applied.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ex :&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;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"my-class another-class"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This paragraph has the combined styles of "my-class" and "another-class".&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, if both "my-class" and "another-class" define conflicting styles, the last defined style or the one with higher specificity will take precedence.  &lt;/p&gt;

&lt;p&gt;Styling classes provide a convenient way to group and reuse CSS styles across multiple elements, allowing for consistent and modular styling throughout your web page.  &lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Specificity :
&lt;/h2&gt;

&lt;p&gt;CSS specificity is a mechanism that determines which styles should be applied to an HTML element when multiple CSS rules target the same element. Specificity helps resolve conflicts when different styles are defined for the same element, allowing you to control the precedence of styles based on their specificity values. Specificity is calculated based on selectors used in CSS rules. Let's dive into the details of CSS specificity:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Specificity Hierarchy:
CSS specificity follows a hierarchy of selector types, from the least specific to the most specific:
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inline Styles: Styles defined directly on an element using the "style" attribute have the highest specificity.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IDs: Selectors targeting elements by their ID attribute have a higher specificity than other selector types. For example, &lt;code&gt;#myId&lt;/code&gt;.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Classes, Attributes, and Pseudo-Classes: Selectors targeting elements by their class, attribute, or pseudo-class have a medium specificity. For example, &lt;code&gt;.myClass&lt;/code&gt;, &lt;code&gt;[type="text"]&lt;/code&gt;, &lt;code&gt;:hover&lt;/code&gt;.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Elements and Pseudo-Elements: Selectors targeting elements or pseudo-elements have the lowest specificity. For example, &lt;code&gt;p&lt;/code&gt;, &lt;code&gt;::before&lt;/code&gt;.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Calculating Specificity:
Specificity is calculated by assigning a weight to each selector type within a CSS rule. The weights are represented by a four-component value called the specificity value. The components, from left to right, represent the weight of inline styles, IDs, classes/attributes/pseudo-classes, and elements/pseudo-elements.
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The specificity value is calculated by counting the number of occurrences of each selector type and concatenating the counts. For example, a selector with two classes and one element would have a specificity value of 0111.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If a higher component has a tie, the next component is considered. For example, a selector with one ID and one class has a higher specificity than a selector with three classes.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The specificity value is always a non-negative integer, and the higher the value, the more specific the selector.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Resolving Conflicts:
When multiple CSS rules target the same element and have conflicting styles, the rule with the highest specificity value takes precedence. If two or more rules have the same specificity value, the rule defined later in the CSS document or file overrides the earlier one.
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inline styles always override external stylesheets and styles defined in the "style" attribute.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rules with higher specificity override rules with lower specificity, regardless of their order.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Specificity Examples:
Let's consider a few examples to understand specificity better:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Rule 1 */&lt;/span&gt;  
&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="c"&gt;/* Rule 2 */&lt;/span&gt;  
&lt;span class="nc"&gt;.header&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="c"&gt;/* Rule 3 */&lt;/span&gt;  
&lt;span class="nf"&gt;#myId&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="c"&gt;/* Rule 4 */&lt;/span&gt;  
&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="nf"&gt;#myId&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;orange&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"myId"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"header"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hello, CSS!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the color of the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; element will be orange because Rule 4 has the highest specificity, targeting the element by both its ID and element type. If Rule 4 were not present, Rule 3 would apply due to its higher specificity than Rule 2. Rule 1 has the lowest specificity and would only apply if none of the other rules matched.&lt;/p&gt;

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

&lt;p&gt;CSS responsive queries, also known as media queries, allow you to apply different CSS styles based on the characteristics of the device or viewport size. Media queries are commonly used in responsive web design to create adaptable layouts and optimize the display of content on different devices. Here's how you can use media queries in CSS:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Syntax:
Media queries are written using the &lt;code&gt;@media&lt;/code&gt; rule followed by a condition enclosed in parentheses. The condition specifies the characteristics of the device or viewport size that you want to target.
&lt;/li&gt;
&lt;/ol&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;condition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="c"&gt;/* CSS rules to apply when the condition is true */&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Device Characteristics:
Media queries can target various device characteristics, including viewport width, device type, resolution, orientation, etc. Some commonly used conditions include:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(i) - Viewport Width:&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="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;/* CSS rules for screens with a maximum width of 768 pixels */&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&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;768px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;and&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;1024px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c"&gt;/* CSS rules for screens with a width between 768 and 1024 pixels */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(ii) - Device Type:&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="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="c"&gt;/* CSS rules for screens */&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;print&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="c"&gt;/* CSS rules for print styles */&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(iii) - Resolution:&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="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-resolution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300dpi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="c"&gt;/* CSS rules for devices with a minimum resolution of 300dpi */&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-resolution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;72dpi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="c"&gt;/* CSS rules for devices with a maximum resolution of 72dpi */&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(iv) - Orientation:&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="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orientation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;landscape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="c"&gt;/* CSS rules for landscape orientation */&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orientation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;portrait&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="c"&gt;/* CSS rules for portrait orientation */&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Applying Styles:
Inside a media query block, you can include CSS rules that will be applied when the specified condition is true. These rules can override or modify existing styles or introduce new styles specific to the targeted condition.
&lt;/li&gt;
&lt;/ol&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="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
&lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;14px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="nc"&gt;.container&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;100%&lt;/span&gt;&lt;span class="p"&gt;;&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, when the viewport width is 768 pixels or less, the font size of the &lt;code&gt;body&lt;/code&gt; element will be 14 pixels, and the width of the elements with the class &lt;code&gt;.container&lt;/code&gt; will be set to 100%.  &lt;/p&gt;

&lt;p&gt;By utilizing media queries, you can create responsive designs that adapt to different screen sizes, orientations, and other device characteristics. This allows you to optimize the user experience across a range of devices and improve the accessibility of your website or application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flexbox/Grid :
&lt;/h2&gt;

&lt;p&gt;Flex Layout and Grid Layout are two popular CSS layout systems used to create responsive and flexible web designs. They offer different approaches to organizing and positioning elements on a webpage.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Flex Layout:
Flexbox, also known as Flexible Box Layout, is a one-dimensional layout system designed for arranging elements along a single axis (either horizontally or vertically) within a container. It provides an easy way to create flexible and dynamic layouts. Here are some key features of Flex Layout:
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Container and Items: The flex layout involves a container element (parent) and its child elements (items). The container is defined using the CSS property &lt;code&gt;display: flex&lt;/code&gt;, while the child elements become flex items.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Main and Cross Axis: Flexbox works with a main axis and a cross axis. By default, the main axis is horizontal (from left to right) and the cross axis is vertical. However, you can change the direction as needed.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flexbox Properties: Flexbox offers several CSS properties to control the behavior of the layout, such as &lt;code&gt;flex-direction&lt;/code&gt;, &lt;code&gt;justify-content&lt;/code&gt;, &lt;code&gt;align-items&lt;/code&gt;, and &lt;code&gt;flex-grow&lt;/code&gt;. These properties allow you to control the alignment, distribution, and resizing of flex items.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Responsive Design: Flexbox simplifies responsive design by providing features like &lt;code&gt;flex-wrap&lt;/code&gt; and &lt;code&gt;media queries&lt;/code&gt; that allow items to wrap or change their layout based on available space.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Flex Layout is commonly used for creating navigation menus, flexible content containers, and vertical alignment of elements.&lt;br&gt;
&lt;/p&gt;

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

HTML:  
&amp;lt;div class="container"&amp;gt;  
&amp;lt;div class="item"&amp;gt;Item 1&amp;lt;/div&amp;gt;  
&amp;lt;div class="item"&amp;gt;Item 2&amp;lt;/div&amp;gt;  
&amp;lt;div class="item"&amp;gt;Item 3&amp;lt;/div&amp;gt;  
&amp;lt;/div&amp;gt;  

CSS :  
.container {  
display: flex;  
justify-content: space-between;  
}  

.item {  
flex: 1;  
background-color: #e0e0e0;  
padding: 10px;  
margin: 5px;  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Grid Layout:
CSS Grid Layout is a two-dimensional layout system that allows you to create complex and grid-based layouts. It provides more control over the placement and sizing of elements in both rows and columns. Here are some key features of Grid Layout:
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Grid Container and Items: Grid Layout uses a grid container (parent) and its child elements (items). The container is defined using the CSS property &lt;code&gt;display: grid&lt;/code&gt;, and the child elements become grid items.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rows and Columns: You can define the number and size of rows and columns in the grid using properties like &lt;code&gt;grid-template-rows&lt;/code&gt; and &lt;code&gt;grid-template-columns&lt;/code&gt;. You can use fixed lengths, percentages, or flexible units to define the size of grid tracks.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Grid Areas: Grid Layout allows you to define named grid areas using the &lt;code&gt;grid-template-areas&lt;/code&gt; property. This makes it easier to place items in specific areas of the grid.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Alignment and Spacing: Grid Layout provides properties like &lt;code&gt;justify-items&lt;/code&gt;, &lt;code&gt;align-items&lt;/code&gt;, &lt;code&gt;justify-content&lt;/code&gt;, and &lt;code&gt;align-content&lt;/code&gt; to control the alignment and spacing of items within the grid.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Responsive Design: Grid Layout works well for responsive design by using media queries to change the grid structure or redefine grid-template-areas based on different viewport sizes.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Grid Layout is commonly used for creating complex page layouts, such as magazine-style designs, image galleries, and dashboard layouts.&lt;br&gt;
&lt;/p&gt;

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

HTML :  
&amp;lt;div class="container"&amp;gt;  
&amp;lt;div class="item"&amp;gt;Item 1&amp;lt;/div&amp;gt;  
&amp;lt;div class="item"&amp;gt;Item 2&amp;lt;/div&amp;gt;  
&amp;lt;div class="item"&amp;gt;Item 3&amp;lt;/div&amp;gt;  
&amp;lt;div class="item"&amp;gt;Item 4&amp;lt;/div&amp;gt;  
&amp;lt;/div&amp;gt;  

CSS :  
.container {  
display: grid;  
grid-template-columns: 1fr 1fr;  
grid-gap: 10px;  
}  

.item {  
background-color: #e0e0e0;  
padding: 10px;  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Common html meta tags :
&lt;/h2&gt;

&lt;p&gt;The HTML &lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt; tag is used to provide metadata about an HTML document. It is placed within the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of an HTML page. Here's an explanation of the commonly used attributes of the &lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt; tag:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;charset&lt;/code&gt;&lt;/strong&gt;: Specifies the character encoding for the HTML document. It helps browsers interpret and display the text correctly.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&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;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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;name&lt;/code&gt; and &lt;code&gt;content&lt;/code&gt;&lt;/strong&gt;: These attributes work together to define various types of metadata. The &lt;code&gt;name&lt;/code&gt; attribute specifies the type of metadata, while the &lt;code&gt;content&lt;/code&gt; attribute provides the actual value.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Examples:&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;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 a description of the page."&lt;/span&gt;&lt;span class="nt"&gt;&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;"HTML, meta tags, example"&lt;/span&gt;&lt;span class="nt"&gt;&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;http-equiv&lt;/code&gt;&lt;/strong&gt;: Used to simulate an HTTP response header field within an HTML document. It can be used to set the behavior of the browser or define the document's caching policies.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&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;meta&lt;/span&gt; &lt;span class="na"&gt;http-equiv=&lt;/span&gt;&lt;span class="s"&gt;"refresh"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"5; URL=[https://example.com](https://example.com/)"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;viewport&lt;/code&gt;&lt;/strong&gt;: Primarily used for responsive web design, it specifies the viewport's width and initial scale for mobile devices.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&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;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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's an example of a complete &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of an HTML page with multiple &lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt; tags:&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="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&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;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 a description of the page."&lt;/span&gt;&lt;span class="nt"&gt;&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;"HTML, meta tags, example"&lt;/span&gt;&lt;span class="nt"&gt;&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;meta&lt;/span&gt; &lt;span class="na"&gt;http-equiv=&lt;/span&gt;&lt;span class="s"&gt;"refresh"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"5; URL=[https://example.com](https://example.com/)"&lt;/span&gt;&lt;span class="nt"&gt;&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;title&amp;gt;&lt;/span&gt;Example Page&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;  
&lt;span class="c"&gt;&amp;lt;!-- Page content goes here --&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>SOLID Principle</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Mon, 15 May 2023 12:11:46 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/-solid-principle-4fkb</link>
      <guid>https://dev.to/ankit_dagar/-solid-principle-4fkb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The SOLID principle was introduced by Robert C. Martin, also known as Uncle Bob and it is a coding standard in programming. The SOLID principles are a set of five design principles that are commonly used in object-oriented programming to create more maintainable and scalable software. This principle is an acronym of the five principles which is given below…  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1) Single Responsibility Principle (SRP)&lt;br&gt;
2) Open/Closed Principle (OCP)&lt;br&gt;
3) Liskov’s Substitution Principle (LSP) &lt;br&gt;
4) Interface Segregation Principle (ISP)&lt;br&gt;
5) Dependency Inversion Principle (DIP)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The SOLID principle helps in reducing tight coupling. Tight coupling means a group of classes are highly dependent on one another which you should avoid in your code.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Single Responsibility Principle :
&lt;/h2&gt;

&lt;p&gt;This principle states that “a class should have only one reason to change” which means every class should have a single responsibility or single job or single purpose. Take the example of developing software. The task is divided into different members doing different things as front-end designers do design, the tester does testing and backend developer takes care of backend development part then we can say that everyone has a single job or responsibility.&lt;/p&gt;

&lt;p&gt;Most of the time it happens that when programmers have to add features or new behavior they implement everything into the existing class which is completely wrong. It makes their code lengthy, complex and consumes time when later something needs to be modified. Use layers in your application and break God classes into smaller classes or modules.&lt;br&gt;
For example :-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Logger:  
    def log(self, message):  
        with open('log.txt', 'a') as f:
            f.write(message + '\n')  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the Logger class has only one responsibility, which is to log messages to a file. It doesn't have any other responsibilities, such as sending emails or writing to a database.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Open/Closed Principle:
&lt;/h2&gt;

&lt;p&gt;This principle states that “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification” which means you should be able to extend a class behavior, without modifying it. For example :-&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 speak(self):
        pass

class Dog(Animal):
        def speak(self):
            return "Woof!"

class Cat(Animal):
        def speak(self):
            return "Meow!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the Animal class is closed for modification, but open for extension. You can add new subclasses (such as Dog and Cat) without modifying the Animal class.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Liskov’s Substitution Principle:
&lt;/h2&gt;

&lt;p&gt;The principle was introduced by Barbara Liskov in 1987 and according to this principle “Derived or child classes must be substitutable for their base or parent classes“. This principle ensures that any class that is the child of a parent class should be usable in place of its parent without any unexpected behavior.&lt;br&gt;
&lt;/p&gt;

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

    def area(self):  
        return self.width * self.height  

class Square(Rectangle):  
    def __init__(self, size):  
        self.width = size  
        self.height = size  

    def area(self):  
        return self.width * self.height
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One of the classic examples of this principle is a rectangle having four sides. A rectangle’s height can be any value and width can be any value. A square is a rectangle with equal width and height. So we can say that we can extend the properties of the rectangle class into square class. In order to do that you need to swap the child (square) class with parent (rectangle) class to fit the definition of a square having four equal sides but a derived class does not affect the behavior of the parent class so if you will do that it will violate the Liskov Substitution Principle.  &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Interface Segregation Principle:
&lt;/h2&gt;

&lt;p&gt;This principle is the first principle that applies to Interfaces instead of classes in SOLID and it is similar to the single responsibility principle. It states that “do not force any client to implement an interface which is irrelevant to them“.&lt;br&gt;&lt;br&gt;
This principle states that a class should not be forced to depend on methods it does not use. In other words, a class should only depend on the methods it actually needs. For example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Machine:  
    def print_document(self):  
        pass
    def scan_document(self):  
        pass  

class Printer(Machine):  
    def print_document(self):  
        print("Printing document...")

class Scanner(Machine):  
    def scan_document(self):  
        print("Scanning document...")  

class Copier(Machine):  
    def __init__(self):  
        self.printer = Printer()  
        self.scanner = Scanner()  

    def print_document(self):  
        self.printer.print_document()  

    def scan_document(self):  
        self.scanner.scan_document()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the Copier class only depends on the methods it needs from the Printer and Scanner classes. It doesn't need the scan_document method from the Printer class or the print_document method from the Scanner class.  &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Dependency Inversion Principle:
&lt;/h2&gt;

&lt;p&gt;Two key points are here to keep in mind about this principle :  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;High-level modules/classes should not depend on low-level modules/ classes. Both should depend upon abstractions.
&lt;/li&gt;
&lt;li&gt;Abstractions should not depend upon details. Details should depend upon abstractions.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example:
Violation of DIP

class BackendDeveloper:
    """This is a low-level module"""
    @staticmethod
    def python():
        print("Writing Python code")
class FrontendDeveloper:
    """This is a low-level module"""
    @staticmethod
    def javascript():
        print("Writing JavaScript code")
class Project:
    """This is a high-level module"""
    def __init__(self):
        self.backend = BackendDeveloper()
        self.frontend = FrontendDeveloper()
    def develop(self):
        self.backend.python()
        self.frontend.javascript()
        return "Develop codebase"
project = Project()
print(project.develop())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The project class is a high-level module and backend &amp;amp; frontend are the low-level modules. In this example, we found that the high-level module depends on the low-level module. Hence this example are violated the Dependency Inversion Principle. Let’s solve the problem according to the definition of DIP.&lt;br&gt;
Solution:&lt;br&gt;
&lt;/p&gt;

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

class BackendDeveloper:
   """This is a low-level module"""
   def develop(self):
       self.__python_code()
   @staticmethod
   def __python_code():
       print("Writing Python code")
class FrontendDeveloper:
   """This is a low-level module"""
   def develop(self):
       self.__javascript()
   @staticmethod
   def __javascript():
       print("Writing JavaScript code")
class Developers:
   """An Abstract module"""
   def __init__(self):
       self.backend = BackendDeveloper()
       self.frontend = FrontendDeveloper()
   def develop(self):
       self.backend.develop()
       self.frontend.develop()
class Project:
   """This is a high-level module"""
   def __init__(self):
       self.__developers = Developers()
   def develops(self):
       return self.__developers.develop()
project = Project()
print(project.develops())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/solid-principles-explained-in-plain-english/"&gt;https://www.freecodecamp.org/news/solid-principles-explained-in-plain-english/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.baeldung.com/solid-principles"&gt;https://www.baeldung.com/solid-principles&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.pythontutorial.net/python-oop/python-open-closed-principle/"&gt;https://www.pythontutorial.net/python-oop/python-open-closed-principle/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@alex24dutertre/square-rectangle-and-the-liskov-substitution-principle-ee1eb8433106"&gt;https://medium.com/@alex24dutertre/square-rectangle-and-the-liskov-substitution-principle-ee1eb8433106&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.bmc.com/blogs/solid-design-principles/"&gt;https://www.bmc.com/blogs/solid-design-principles/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Some Topics in PostgreSQL</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Fri, 12 May 2023 12:47:15 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/some-topics-in-postgresql-4oh0</link>
      <guid>https://dev.to/ankit_dagar/some-topics-in-postgresql-4oh0</guid>
      <description>&lt;h3&gt;
  
  
  1. Transactions :-
&lt;/h3&gt;

&lt;p&gt;A logical unit of work on database.&lt;br&gt;
An action or series of action that are performed by a single user or application program, which reads or updates the contents of a database. It must follow all the acid properties. &lt;/p&gt;

&lt;p&gt;For example :- When i send money to my friend the updation of the data is happending it is a action which is performing here. &lt;/p&gt;
&lt;h3&gt;
  
  
  ACID
&lt;/h3&gt;
&lt;h4&gt;
  
  
  A -&amp;gt; Atomicity :
&lt;/h4&gt;

&lt;p&gt;The hole transaction takes place at on ce or does not happen at all. If something happen in between transaction will cancel out.&lt;/p&gt;

&lt;p&gt;For example :- When i send money to my friend if something happen in between my friend will not get the money and the money will be deducted from my account for perventing this we use atomicity&lt;/p&gt;
&lt;h4&gt;
  
  
  C -&amp;gt; Consistency :
&lt;/h4&gt;

&lt;p&gt;It means correctness that any given database transaction must change affected data only in allowed ways. For a database to be consistent, data written to the database must be valid according to all defined rules, including constraints, cascades, triggers, or any combination. &lt;br&gt;
For example :- When is send money to my friend the sum of my balance after and before the transaction should br equal to the sum of the balance of my friend before and after the transaction.&lt;/p&gt;
&lt;h4&gt;
  
  
  I -&amp;gt; Isolation:
&lt;/h4&gt;

&lt;p&gt;It means that if multiple transaction is happening &lt;br&gt;
This property ensures that transactions are isolated from one another, and each transaction must behave as if it's the only transaction being executed on the database. In other words, the changes made by one transaction should not be visible to other transactions until the first transaction has been completed.&lt;/p&gt;
&lt;h4&gt;
  
  
  D -&amp;gt; Durability:
&lt;/h4&gt;

&lt;p&gt;This property ensures that once a transaction is committed, its changes will be permanent and will survive any subsequent system failures, such as power outages or hardware failures. In other words, once a transaction is committed, the changes made during that transaction will be stored on disk and will not be lost even if the database crashes or the system shuts down unexpectedly.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. CAP Theorem
&lt;/h3&gt;

&lt;p&gt;The CAP theorem is a theorem about distributed computing systems. It states that a computer system can at best provide two of the three properties.&lt;/p&gt;
&lt;h4&gt;
  
  
  Consistency :
&lt;/h4&gt;

&lt;p&gt;Consistency means that all clients see the same data at the same time, no matter which node they connect to. For this to happen, whenever data is written to one node, it must be instantly forwarded or replicated to all the other nodes in the system before the write is deemed ‘successful.’&lt;/p&gt;
&lt;h4&gt;
  
  
  Availability :
&lt;/h4&gt;

&lt;p&gt;Availability means that any client making a request for data gets a response, even if one or more nodes are down. Another way to state this—all working nodes in the distributed system return a valid response for any request, without exception.&lt;/p&gt;
&lt;h4&gt;
  
  
  Partition tolerance :
&lt;/h4&gt;

&lt;p&gt;A partition is a communications break within a distributed system—a lost or temporarily delayed connection between two nodes. Partition tolerance means that the cluster must continue to work despite any number of communication breakdowns between nodes in the system.&lt;/p&gt;
&lt;h3&gt;
  
  
  3.Joins
&lt;/h3&gt;

&lt;p&gt;A &lt;code&gt;JOIN&lt;/code&gt; clause is used to combine rows from two or more tables, based on a related column between them. &lt;br&gt;
Joins are of 5 types.&lt;/p&gt;
&lt;h4&gt;
  
  
  1.Inner Join :
&lt;/h4&gt;

&lt;p&gt;It return the common data record that have matching values in both tables.&lt;/p&gt;

&lt;p&gt;Syantax for 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 column_name(s) FROM table1 
INNER JOIN table2 
ON table1.column_name =
table2.column_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2.Left Join :
&lt;/h4&gt;

&lt;p&gt;It returns all records from the left table, and the matched records from the right table.&lt;/p&gt;

&lt;p&gt;Syantax for left 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  column_name(s)  
FROM  table1  
LEFT  JOIN  table2  
ON  table1.column_name = 
table2.column_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3.Right Join :
&lt;/h4&gt;

&lt;p&gt;It returns all records from the right table, and the matched records from the left table.&lt;/p&gt;

&lt;p&gt;Syantax for right 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 column_name(s)  
FROM table1
RIGHT JOIN table2
ON table1.column_name_ =
table2.column_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4.Full Outer Join :
&lt;/h4&gt;

&lt;p&gt;It returns all records all the data from both the table either there is a match or not.&lt;/p&gt;

&lt;p&gt;Syantax for full 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 column_name(s)  
FROM  table1
FULL  OUTER  JOIN table2  
ON table1.column_name = table2.column_name WHERE condition;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5.Self Join :
&lt;/h4&gt;

&lt;p&gt;A self join is a regular join, but the table is joined with itself.&lt;br&gt;
Syantax for self 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  column_name(s)  
FROM  table1 T1, table1 T2  
WHERE  condition;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Indexes
&lt;/h3&gt;

&lt;p&gt;Indexes are used to retrieve data from the database more quickly than otherwise. The users cannot see the indexes, they are just used to speed up searches/queries.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;CREATE INDEX&lt;/code&gt; statement is used to create indexes in tables.&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  index_name  
ON  table_name (column1, column2, ...);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.Triggers
&lt;/h3&gt;

&lt;p&gt;It is a stored procedure in database which automatically invokes whenever a special event in the database occurs.&lt;/p&gt;

&lt;p&gt;For example:- A trigger can be invoked when a row is inserted into a specified table or when certain table columns are being updated.&lt;/p&gt;

&lt;p&gt;In Structured Query Language, triggers are called only either before or after the below events:&lt;/p&gt;

&lt;h4&gt;
  
  
  INSERT Event :
&lt;/h4&gt;

&lt;p&gt;This event is called when the new row is entered in the table.&lt;/p&gt;

&lt;h4&gt;
  
  
  UPDATE Event:
&lt;/h4&gt;

&lt;p&gt;This event is called when the existing record is changed or modified in the table.&lt;/p&gt;

&lt;h4&gt;
  
  
  DELETE Event:
&lt;/h4&gt;

&lt;p&gt;This event is called when the existing record is removed from the table.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Normalization
&lt;/h3&gt;

&lt;p&gt;Normalization is the process of organizing data in a database. This includes creating tables and establishing relationships between those tables according to rules designed both to protect the data and to make the database more flexible by eliminating redundancy and inconsistent dependency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Normalization&lt;/strong&gt;  divides a database into two or more tables and defines relationships between them.&lt;/p&gt;

&lt;h4&gt;
  
  
  Types of normalization:-
&lt;/h4&gt;

&lt;p&gt;Each table represents a distinct entity or concept, and the relationships between the tables are based on the attributes that they share.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;1NF:&lt;/strong&gt;  A relation is in 1NF if all its attributes have an atomic value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;2NF:&lt;/strong&gt;  A relation is in 2NF if it is in 1NF and all non-key attributes are fully functional dependent on the candidate key in DBMS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;3NF:&lt;/strong&gt;  A relation is in 3NF if it is in 2NF and there is no transitive dependency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;BCNF:&lt;/strong&gt;  A relation is in BCNF if it is in 3NF and for every Functional Dependency, LHS is the super key.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  7. Aggregations, Filters in queries
&lt;/h3&gt;

&lt;p&gt;Aggregations and filters are common operations used in SQL queries to summarize and manipulate data.&lt;/p&gt;

&lt;h4&gt;
  
  
  Some common aggregations:-
&lt;/h4&gt;

&lt;h5&gt;
  
  
  1.  sum :
&lt;/h5&gt;

&lt;p&gt;To calculate total column values.&lt;/p&gt;

&lt;h5&gt;
  
  
  2.  AVG :
&lt;/h5&gt;

&lt;p&gt;It returns the average value of a numeric column.&lt;/p&gt;

&lt;h5&gt;
  
  
  3.  count :
&lt;/h5&gt;

&lt;p&gt;It returns the number of rows that matches a specified criterion.&lt;/p&gt;

&lt;h5&gt;
  
  
  4. MAX :
&lt;/h5&gt;

&lt;p&gt;It return max value of column.&lt;/p&gt;

&lt;h5&gt;
  
  
  5. MIN :
&lt;/h5&gt;

&lt;p&gt;It returns min value of column&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some filter technique:-&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;WHERE&lt;/strong&gt;&lt;br&gt;
The WHERE clause specifies a condition that must be met for each row to be selected in the result set.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can also use comparison operators such as  &lt;code&gt;less than (&amp;lt;)&lt;/code&gt;  ,  &lt;code&gt;greater than (&amp;gt;)&lt;/code&gt;,  &lt;code&gt;equal to (=)&lt;/code&gt;,  &lt;code&gt;not equal to (!= or &amp;lt;&amp;gt;)&lt;/code&gt;  and logical operators such as  &lt;code&gt;AND&lt;/code&gt;  and  &lt;code&gt;OR&lt;/code&gt;  ,  &lt;code&gt;BETWEEN&lt;/code&gt;  to create more complex filter conditions. Here's an 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 plaintext"&gt;&lt;code&gt;select *
from sales
where (product = 'product_name' and price &amp;gt; 100) or price &amp;gt; 20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8. Locking mechanism
&lt;/h3&gt;

&lt;p&gt;Locking is a fundamental mechanism in database systems that allows&lt;br&gt;&lt;br&gt;
multiple users to access shared resources without interfering with each other.&lt;/p&gt;

&lt;h4&gt;
  
  
  Types of Locking Mechanism :-
&lt;/h4&gt;

&lt;p&gt;There are different types of locking mechanism showing below.&lt;/p&gt;

&lt;h4&gt;
  
  
  Shared lock(S):-
&lt;/h4&gt;

&lt;p&gt;A shared lock can be imposed by several transactions at the same time over the same page or row and in that way several transactions can  &lt;em&gt;share&lt;/em&gt;  the ability for data reading since the reading process itself will not affect anyhow the actual page or row data. In addition, a shared lock will allow write operations, but no DDL changes will be allowed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Exclusive lock :-
&lt;/h4&gt;

&lt;p&gt;The exclusive lock will be imposed by the transaction when it wants to modify the page or row data, which is in the case of DML statements DELETE, INSERT and UPDATE. An exclusive lock can be imposed to a page or row only if there is no other shared or exclusive lock imposed already on the target.&lt;/p&gt;

&lt;h4&gt;
  
  
  Update lock :-
&lt;/h4&gt;

&lt;p&gt;An update lock is acquired when a transaction intends to modify a resource and wants to prevent other transactions from acquiring an exclusive lock on the same resource.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Database Isolation Levels
&lt;/h3&gt;

&lt;p&gt;The SQL standard defines four isolation levels.&lt;/p&gt;

&lt;h3&gt;
  
  
  Read Uncommitted :-
&lt;/h3&gt;

&lt;p&gt;The lowest isolation level allowed by SQL is read uncommitted. In this level, transactions can read data that is not committed by other transactions, permitting dirty read.&lt;/p&gt;

&lt;h3&gt;
  
  
  Read Committed :-
&lt;/h3&gt;

&lt;p&gt;This isolation level allows for the reading of data after it is committed by a transaction. This means no dirty reads are possible. This isolation is unable to prevent non-repeatable reads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Repeatable Read :-
&lt;/h3&gt;

&lt;p&gt;This isolation tries to improve on the previous isolation level by preventing both dirty reads and non-repeatable reads. This prevention is done by applying locks on rows that are read and rows that perform write operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Serializable :-
&lt;/h3&gt;

&lt;p&gt;The highest isolation level allowed is serializable. This isolation level looks like a serial execution, with almost no concurrency. All the three read phenomena are prevented in this isolation level, but it compromises concurrent execution.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Object Oriented Programming</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Thu, 11 May 2023 06:55:14 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/object-oriented-programming-4p17</link>
      <guid>https://dev.to/ankit_dagar/object-oriented-programming-4p17</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Python is an object-oriented language that fully supports OOP concepts.Object-oriented programming (OOP) is a design principle which focuses on the concept of objects, which are instances of classes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Objects :-
&lt;/h2&gt;

&lt;p&gt;In Python, everything is an object. A object is a instance of a class, which is a blueprint or a template for creating objects. Objects in Python have attributes and methods.&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;class  Rectangle: 
    def  __init__(self, length, width):
        self.length = length
        self.width = width
    def  area(self):
        return self.length * self.width
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating a object of rectangle class name rect and passing values in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rect = Rectangle(10, 5)
print(rect.area())
50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Classes :-
&lt;/h2&gt;

&lt;p&gt;In Python, a class is a blueprint or a template for creating objects. A class defines a set of attributes and methods that describe the behavior of the objects created from it.&lt;br&gt;
For making a  &lt;strong&gt;Class&lt;/strong&gt;  in Python. We use  &lt;strong&gt;Class&lt;/strong&gt;  keyword.Here is a example:-&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

    def introduction(self):
        print("Hi, my name is " + self.name + " and I'm " + str(self.age) + " years old.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating an object of Person named class and passing values  in it.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Calling the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p.introduce()
# output:
Hi, my name is Alice and I'm 25 years old.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;It is a concept of creating a new class from an existing class, inheriting all the attributes and methods of the parent class. In Python, we achieved this through the use of the &lt;code&gt;super()&lt;/code&gt; function and &lt;code&gt;isinstance()&lt;/code&gt; function.&lt;br&gt;
 ### 1.  Single inheritance :-&lt;br&gt;
It is the most common type of inheritance, where a subclass inherits from a single parent class. The subclass inherits all the attributes and methods of the parent class.&lt;br&gt;
Here is a example :- In this we are creating a &lt;code&gt;Animal&lt;/code&gt;class and make function inside it named as&lt;code&gt;speak&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

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

    def  __init__(self, name):
        self.name = name

    def  speak(self):
        print("")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a class named as &lt;code&gt;Dog&lt;/code&gt; which is inherited by &lt;code&gt;Animal&lt;/code&gt; 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  Dog(Animal):
    def  speak(self):
        print("Woof!")

dog = Dog("Rover")
print(dog.name) # output : "Rover"
dog.speak() # output: "Woof!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.Multiple inheritance :-
&lt;/h3&gt;

&lt;p&gt;In this a subclass inherits from multiple parent classes. In this case, the subclass inherits all the attributes and methods of each parent class.&lt;br&gt;
Here is example :- In this we are creating a class named &lt;code&gt;Base1&lt;/code&gt; and inside it we are creating a function named as &lt;code&gt;method1&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class  Base1:
    def  method1(self):
        print("Base1 method")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a second class named as &lt;code&gt;Base2&lt;/code&gt; and inside it we are creating a function named as &lt;code&gt;method2&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class  Base2:
    def  method2(self):
        print("Base2 method")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a classnamed as &lt;code&gt;Derived&lt;/code&gt; which is inheriting the class named as &lt;code&gt;Base1&lt;/code&gt;,&lt;code&gt;Base2&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class  Derived(Base1, Base2):
    pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a object of &lt;code&gt;Drived&lt;/code&gt; class and callng the function of &lt;code&gt;Base1&lt;/code&gt; class and &lt;code&gt;Base2&lt;/code&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d = Derived()   
d.method1() # Outputs "Base1 method"
d.method2() # Outputs "Base2 method"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.Multi-level inheritance :-
&lt;/h3&gt;

&lt;p&gt;In this a subclass inherits from a parent class, which in turn inherits from another parent class. In this case, the subclass inherits all the attributes and methods of both parent classes in the hierarchy.&lt;br&gt;
Here is a example :-&lt;br&gt;
Here we are creating a class named as &lt;code&gt;Animal&lt;/code&gt; and passing a value in its constructor.&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 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a class named as &lt;code&gt;Mammal&lt;/code&gt; which is inheriting the properties of &lt;code&gt;Animal&lt;/code&gt; class and inside this we are making a function named as &lt;code&gt;speak&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class  Mammal(Animal):
    def  speak(self):
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a class named as &lt;code&gt;Dog&lt;/code&gt; which is inheriting the properties of &lt;code&gt;Mammal&lt;/code&gt; class, which is inherting the properties of &lt;code&gt;Animal&lt;/code&gt; class and inside this we are making a function named as &lt;code&gt;speak&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class  Dog(Mammal):
    def  speak(self):
        print("Woof!") 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a object &lt;code&gt;Dog&lt;/code&gt; class and passing a value in its constructor and callinf the function and priting them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dog = Dog("Rover")
print(dog.name) # output "Rover" 
dog.speak() # output "Woof!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;It refers to the ability of objects of different classes to be used interchangeably, as long as they share a common interface or base class.&lt;br&gt;
Here is a example :- Here we are creating a class named as &lt;code&gt;Animal&lt;/code&gt; and creating a function named as &lt;code&gt;speak&lt;/code&gt; inside it.&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 speak(self):
        print("The animal makes a sound")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a class named as &lt;code&gt;Dog&lt;/code&gt; which is inherited by &lt;code&gt;Animal&lt;/code&gt; class and creating a function named as &lt;code&gt;speak&lt;/code&gt; inside it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Dog(Animal):
    def speak(self):
        print("The dog barks")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating a class named as &lt;code&gt;Cat&lt;/code&gt; which is inherited by &lt;code&gt;Animal&lt;/code&gt; class and creating a function named as &lt;code&gt;speak&lt;/code&gt; inside it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Cat(Animal):
    def speak(self):
        print("The cat meows")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are creating objects of class &lt;code&gt;Dog&lt;/code&gt;,&lt;code&gt;Cat&lt;/code&gt; named as &lt;code&gt;dog&lt;/code&gt; ,&lt;code&gt;cat&lt;/code&gt; and callingg the &lt;code&gt;speak&lt;/code&gt; function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dog = Dog()
cat = Cat()
dog.speak()  # Outputs "The dog barks"
cat.speak()  # Outputs "The cat meows"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;It refers to the practice of hiding the internal details of an object and providing a public interface for interacting with the object. Encapsulation is achieved through access modifiers, which control the visibility and accessibility of an object's attributes and methods&lt;/p&gt;

&lt;p&gt;Here is a example :-&lt;br&gt;
&lt;/p&gt;

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

    def get_name(self):
        return self._name

    def set_name(self, name):
        self._name = name

person1 = People("Ankit", "Male")
print(person1.get_name())  # output: Ankit
person1.set_name("Aman")
print(person1.get_name())  # output: Aman
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;It refers to the practice of hiding the complexity of an object and exposing only the essential features or interface that the user needs to interact with the object. Abstraction is achieved through abstract classes and abstract methods, which define a common interface for a group of related classes.&lt;br&gt;
Here is the example :-&lt;br&gt;
&lt;/p&gt;

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

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

    @abstractmethod
    def speak(self):
        pass

class Male(Animal):
    def speak(self):
        print("Hello")

class Female(Animal):
    def speak(self):
        print("Hi")

male1 = Male("Ankit", "Male")
female1 = Female("Sona", "Female")

male1.speak()  # output: Hello
female1.speak()  # output: Hi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>String Methods of Python</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Thu, 11 May 2023 04:53:46 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/string-methods-of-python-26ia</link>
      <guid>https://dev.to/ankit_dagar/string-methods-of-python-26ia</guid>
      <description>&lt;h3&gt;
  
  
  1.capitalize() :-
&lt;/h3&gt;

&lt;p&gt;It converts the first character to upper case&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ankit'
&amp;gt;&amp;gt;&amp;gt; astring.capitalize()
'Ankit'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.count() :-
&lt;/h3&gt;

&lt;p&gt;It gives the number of times a specified value occurs in a string&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ankit dagar'
&amp;gt;&amp;gt;&amp;gt; astring.count(a)
&amp;gt;&amp;gt;&amp;gt; astring.count('a')
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.endswith():-
&lt;/h3&gt;

&lt;p&gt;It gives true if the string ends with the specified value&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; filename = "example.txt"
&amp;gt;&amp;gt;&amp;gt; filename.endswith(".txt")
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.find() :-
&lt;/h3&gt;

&lt;p&gt;It searches the string for a specified value and returns the position of where it was found&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ankit dagar'
&amp;gt;&amp;gt;&amp;gt; astring.find('k')
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.format() :-
&lt;/h3&gt;

&lt;p&gt;It formats the specified values in a string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; name = 'Ankit'
&amp;gt;&amp;gt;&amp;gt; age=22
&amp;gt;&amp;gt;&amp;gt; result="my name is {},i am {} year old".format(name,age)
&amp;gt;&amp;gt;&amp;gt; result
'my name is Ankit,i am 22 year old'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.index() :-
&lt;/h3&gt;

&lt;p&gt;It searches the string for a specified value and returns the position of where it was found&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt;&amp;gt; astring.index('K')
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.isdecimal() :-
&lt;/h3&gt;

&lt;p&gt;It gives True if all characters in the string are decimals&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt;&amp;gt; astring.isdecimal()
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.isdigit() :-
&lt;/h3&gt;

&lt;p&gt;It gives True if all characters in the string are digits&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt; astring.isdigit()
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.islower() :-
&lt;/h3&gt;

&lt;p&gt;It gives True if all characters in the string are lower case&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt; astring.islower()
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.isnumeric() :-
&lt;/h3&gt;

&lt;p&gt;It gives True if all characters in the string are numeric&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt; astring.isnumeric()
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11.isspace() :-
&lt;/h3&gt;

&lt;p&gt;It gives True if all characters in the string are whitespaces&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt; astring.isspace()
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12.istitle() :-
&lt;/h3&gt;

&lt;p&gt;It gives True if the string follows the rules of a title&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt; astring.istitle()
False

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  13.isupper() :-
&lt;/h3&gt;

&lt;p&gt;It gives True if all characters in the string are upper case&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt; astring.isupper()
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  14.lower() :-
&lt;/h3&gt;

&lt;p&gt;It converts a string into lower case&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; astring='ANKIT DAGAR'
&amp;gt;&amp;gt;&amp;gt; astring.lower()
'ankit dagar'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;GeeksforGeeks&lt;br&gt;
W3Schools&lt;br&gt;
freecodecamp&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Dictionary Methods of Python</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Thu, 11 May 2023 04:29:56 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/dictionary-methods-of-python-1ioe</link>
      <guid>https://dev.to/ankit_dagar/dictionary-methods-of-python-1ioe</guid>
      <description>&lt;h3&gt;
  
  
  1. items() :-
&lt;/h3&gt;

&lt;p&gt;It gives a list containing a tuple for each key value pair&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; thisdict = {
...   "brand": "Ford",
...   "model": "Mustang",
...   "year": 1964
... }
&amp;gt;&amp;gt;&amp;gt; thisdict.items()
dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 1964)])

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. clear() :-
&lt;/h3&gt;

&lt;p&gt;It removes all the elements from the dictionary&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; thisdict.clear()
&amp;gt;&amp;gt;&amp;gt; thisdict
{}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. copy() :-
&lt;/h3&gt;

&lt;p&gt;It gives a copy of the dictionary&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; newdict=thisdict.copy()
&amp;gt;&amp;gt;&amp;gt; newdict
{'brand': 'Ford', 'model': 'Mustang', 'year': 1964}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. fromkeys() :-
&lt;/h3&gt;

&lt;p&gt;it is used to create a new dictionary  with keys from the old dictionary list .&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; newDict=dict.fromkeys(thisdict,'ankit')
&amp;gt;&amp;gt;&amp;gt; newDict
{'brand': 'ankit', 'model': 'ankit', 'year': 'ankit'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. get() :-
&lt;/h3&gt;

&lt;p&gt;It gives the value of the specified key&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; newDict.get('brand')
'ankit'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. keys() :-
&lt;/h3&gt;

&lt;p&gt;It gives a list containing the dictionary's keys&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; newDict.keys()
dict_keys(['brand', 'model', 'year'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. pop() :-
&lt;/h3&gt;

&lt;p&gt;It removes the element with the specified key&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; newdict.pop('brand')
'Ford'
&amp;gt;&amp;gt;&amp;gt; newdict
{'model': 'Mustang', 'year': 1964}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8. popitem() :-
&lt;/h3&gt;

&lt;p&gt;It removes the last inserted key-value pair&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; newdict.popitem()
('year', 1964)
&amp;gt;&amp;gt;&amp;gt; newdict
{'model': 'Mustang'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9. setdefault() :-
&lt;/h3&gt;

&lt;p&gt;It gives the value of the specified key. If the key does not exist: insert the key, with the specified value&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; newdict.setdefault('year',1964)
1964
&amp;gt;&amp;gt;&amp;gt; newdict
{'model': 'Mustang', 'year': 1964}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10. update() :-
&lt;/h3&gt;

&lt;p&gt;It updates the dictionary with the specified key-value pairs&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; fruits1 = {'apple': 2, 'banana': 3}
&amp;gt;&amp;gt;&amp;gt; fruits2 = {'orange': 4, 'pear': 1}
&amp;gt;&amp;gt;&amp;gt; fruits1.update(fruits2)
&amp;gt;&amp;gt;&amp;gt; fruits1
{'apple': 2, 'banana': 3, 'orange': 4, 'pear': 1}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11. values() :-
&lt;/h3&gt;

&lt;p&gt;It returns a list of all the values in the dictionary&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; fruits1
{'apple': 2, 'banana': 3, 'orange': 4, 'pear': 1}
&amp;gt;&amp;gt;&amp;gt; fruits1.values()
dict_values([2, 3, 4, 1])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;GeeksforGeeks&lt;br&gt;
W3Schools&lt;br&gt;
freecodecamp&lt;/p&gt;

</description>
    </item>
    <item>
      <title>List Methods of Python</title>
      <dc:creator>Ankit Dagar</dc:creator>
      <pubDate>Wed, 10 May 2023 15:54:34 +0000</pubDate>
      <link>https://dev.to/ankit_dagar/list-methods-of-python-3ail</link>
      <guid>https://dev.to/ankit_dagar/list-methods-of-python-3ail</guid>
      <description>&lt;h3&gt;
  
  
  1. append() :-
&lt;/h3&gt;

&lt;p&gt;It add the element in the last of the list.&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist=[]
&amp;gt;&amp;gt;&amp;gt; alist.append(1)
&amp;gt;&amp;gt;&amp;gt; alist.append(2)
&amp;gt;&amp;gt;&amp;gt; alist.append(3)
&amp;gt;&amp;gt;&amp;gt; alist
[1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. clear() :-
&lt;/h3&gt;

&lt;p&gt;It delete all the elements of the list.&lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist.clear()
&amp;gt;&amp;gt;&amp;gt; alist
[]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. copy() :-
&lt;/h3&gt;

&lt;p&gt;It returns a copy of a list.&lt;br&gt;
example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist.append(1)
&amp;gt;&amp;gt;&amp;gt; alist.append(2)
&amp;gt;&amp;gt;&amp;gt; alist.append(3)
&amp;gt;&amp;gt;&amp;gt; blist=[]
&amp;gt;&amp;gt;&amp;gt; blist=alist.copy()
&amp;gt;&amp;gt;&amp;gt; blist
[1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. count()  :-
&lt;/h3&gt;

&lt;p&gt;it counts the number of a elements present in a list&lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; blist=[1, 2, 3, 1]
&amp;gt;&amp;gt;&amp;gt; blist.count(1)
2

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. extend() :-
&lt;/h3&gt;

&lt;p&gt;It add the elements of a list in the end of a new list. &lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist.extend(blist)
&amp;gt;&amp;gt;&amp;gt; alist
[1, 2, 3, 1, 2, 3]

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. index() :-
&lt;/h3&gt;

&lt;p&gt;It returns the index of a first occurance of a specified value in a list.&lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist.index(2)
1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. insert() :-
&lt;/h3&gt;

&lt;p&gt;It insert a element at a specified index position.&lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist.insert(-1,4)
&amp;gt;&amp;gt;&amp;gt; alist
[1, 2, 3, 1, 2, 4, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8. pop() :-
&lt;/h3&gt;

&lt;p&gt;It removes the last element or the element on the given index.&lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist.pop(-2)
4
&amp;gt;&amp;gt;&amp;gt; alist
[1, 2, 3, 1, 2, 3]
&amp;gt;&amp;gt;&amp;gt; alist.pop()
3
&amp;gt;&amp;gt;&amp;gt; alist
[1, 2, 3, 1, 2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9. remove() :
&lt;/h3&gt;

&lt;p&gt;It removes the first occurance of the specified element in a list.&lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist.remove(3)
&amp;gt;&amp;gt;&amp;gt; alist
[1, 2, 1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10. reverse() :-
&lt;/h3&gt;

&lt;p&gt;It reverses the order of the list.&lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; alist.reverse()
&amp;gt;&amp;gt;&amp;gt; alist
[2, 1, 3, 2, 1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11. sort() :-
&lt;/h3&gt;

&lt;p&gt;It sorts the order of a list.&lt;br&gt;
example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;alist.sort()
&amp;gt;&amp;gt;&amp;gt;alist
[1, 1, 2, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;GeeksforGeeks&lt;br&gt;
W3Schools&lt;br&gt;
freecodecamp&lt;/p&gt;

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