<?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: Roshansahurk</title>
    <description>The latest articles on DEV Community by Roshansahurk (@roshansahurk).</description>
    <link>https://dev.to/roshansahurk</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%2F1019336%2Fa4a065f4-f4e1-479f-ba42-7176ce937341.png</url>
      <title>DEV Community: Roshansahurk</title>
      <link>https://dev.to/roshansahurk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/roshansahurk"/>
    <language>en</language>
    <item>
      <title>Selenium</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Fri, 07 Apr 2023 09:57:38 +0000</pubDate>
      <link>https://dev.to/roshansahurk/selenium-n4j</link>
      <guid>https://dev.to/roshansahurk/selenium-n4j</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Selenium&lt;/strong&gt; is an open-source testing tool that is widely used for automating web browsers. &lt;/li&gt;
&lt;li&gt;It provides a suite of tools for automating web applications for testing purposes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Why Selenium?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;There are various other tools for automating web browsers such as &lt;strong&gt;Appium, Robot framework, Katalon Studio, Cypress, Jmeter, SoapUI&lt;/strong&gt; etc. &lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In recent years, selenium gained popularity because of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Supports multiple programming languages such as &lt;em&gt;Java, Python, C#, Ruby, JavaScript, and more.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Supports multiple browsers such as &lt;em&gt;Chrome, Firefox, Edge, Safari, and more.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Supports various frameworks and tools for test reporting and test management, such as &lt;em&gt;TestNG, JUnit, Maven, Jenkins, and more.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;It offers three main components:

&lt;ol&gt;
&lt;li&gt;Selenium ID&lt;/li&gt;
&lt;li&gt;Selenium WebDriver&lt;/li&gt;
&lt;li&gt;Selenium Grid.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Selenium IDE is a record and playback tool used for creating simple test cases in a browser.&lt;/li&gt;
&lt;li&gt;Selenium WebDriver is a powerful automated testing tool that provides a programming interface to create and execute complex test cases.&lt;/li&gt;
&lt;li&gt;Selenium Grid is a distributed testing tool that allows running tests in parallel on multiple machines and browsers simultaneously.&lt;/li&gt;
&lt;li&gt;We will be mainly focusing on Webdriver. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;Selenium 4 and above versions are used here. You should have prior knowledge of Python.&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Get started with Selenium
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Open the terminal and the below command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;selenium
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The installation entirely depends on your usage. You can install it globally as well in your virtual environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the below package&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;webdriver-manager 
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Why web driver-manager?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The WebDriver Manager automates the process of downloading and configuring WebDrivers for different browsers, which reduces the effort required to manage multiple versions of WebDrivers manually.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Firefox&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Firefox
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium.webdriver.firefox.service&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;FirefoxService&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;webdriver_manager.firefox&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;GeckoDriverManager&lt;/span&gt;

&lt;span class="n"&gt;driver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Firefox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;FirefoxService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GeckoDriverManager&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can find the link in the reference section for different browsers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Basics of Selenium
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Open the browser using Selenium.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;driver&lt;/strong&gt; is the object instantiation in the web driver class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;The object *driver&lt;/em&gt; will be used to perform various tasks.*&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Chrome
# import webdriver from selenium
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium.webdriver.chrome.service&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ChromeService&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;webdriver_manager.chrome&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ChromeDriverManager&lt;/span&gt;

&lt;span class="c1"&gt;# The below line of code opens up a browser.
&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Chrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ChromeService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ChromeDriverManager&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h2&gt;
  
  
  2. Navigate to the URL in a browser
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;driver.get(url)&lt;/strong&gt; is a method to open the webpage in the browser. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;driver.forward()&lt;/strong&gt; moves forward into the browser's history if present.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;driver.back()&lt;/strong&gt; moves back into the browser's history. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can also open the &lt;code&gt;folder/file&lt;/code&gt; in the browser by providing the path of the &lt;code&gt;folder/file&lt;/code&gt; instead of url.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"http://www.python.org"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;back&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h2&gt;
  
  
  3. Setting the browser size
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You can set a custom size/position, fullscreen or maximize the window of the browser.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Maximise Window
&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;maximize_window&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;#FullScreen
&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fullscreen_window&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;#Set Window Size
&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_window_size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#Set Window Position
&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_window_position&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#Get Window Size
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_window_size&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="c1"&gt;#Get Window Position
&lt;/span&gt;&lt;span class="n"&gt;window_pos&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_window_position&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;window_pos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#Page refresh command
&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h2&gt;
  
  
  4. Interaction with page
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To interact with the pages, or, more specifically, the HTML elements within a page. First of all, we need to find one. WebDriver offers several ways to find elements. For example, given an element defined as:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"passwd"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"passwd-id"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You could find it using any of:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium.webdriver.common.by&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;By&lt;/span&gt;

&lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"passwd-id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"passwd"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;XPATH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"//input[@id='passwd-id']"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CSS_SELECTOR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"input#passwd-id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use devtools to get the &lt;em&gt;Id, Name, Xpath or CSS_Selector.&lt;/em&gt; These are often refferred as locators.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After finding the element various operations can be performed on the elements such as &lt;code&gt;click&lt;/code&gt;, &lt;code&gt;drag and drop&lt;/code&gt;, &lt;code&gt;hold&lt;/code&gt;, &lt;code&gt;hover&lt;/code&gt;, &lt;code&gt;text&lt;/code&gt; inside the element, &lt;code&gt;clear&lt;/code&gt; the text, &lt;code&gt;toggle&lt;/code&gt;, &lt;code&gt;select&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For instance, we will see the common actions performed on the elements.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;click&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# Performs a click on the element 
&lt;/span&gt;
&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'some-text'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# Adds a text inside the input element
&lt;/span&gt;
&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# Clears the text in the input element
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Perform a drag and drop&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium.webdriver&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ActionChains&lt;/span&gt;

&lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;action_chains&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ActionChains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;action_chains&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drag_and_drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;perform&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BONUS:&lt;/strong&gt; &lt;em&gt;&lt;code&gt;While using actionchains() class always use .perform() at the end to perform the specific action. Actionchains() are used to trigger the mouse events in the browser. If you forget to write .perform(), the mouse events will fail to run. Although it won't through an error, you will not be able to use the mouse events&lt;/code&gt;&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Moving between windows&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;How do you know the window name?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Take a look at the javascript or link that opened it:
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"somewhere.html"&lt;/span&gt; &lt;span class="na"&gt;target=&lt;/span&gt;&lt;span class="s"&gt;"windowName"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Click here to open a new window&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;     
&lt;/code&gt;&lt;/pre&gt;




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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;switch_to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"windowName"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Alternatively, you can also find by &lt;strong&gt;driver.window_handles&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;driver.window_handles&lt;/strong&gt; returns a list with hashcodes of the window, pass the hashcode instead of &lt;code&gt;windowName&lt;/code&gt; in the above code. If you are not comfortable with hashcodes then feel free to use the above method.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BONUS:&lt;/strong&gt; &lt;em&gt;&lt;code&gt;At times your browser will open a new tab. If you locate that element in the browser without changing the current handle of the browser then it will raise an error. So it is important that when your browser opens a new tab and if you want to work with the element in that tab then  switch to that window.&lt;/code&gt;&lt;/em&gt; &lt;/li&gt;
&lt;/ul&gt;


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

&lt;h1&gt;
  
  
  Waits
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When a page is loaded by the browser, the elements within that page may load at different time intervals. This makes locating elements difficult: if an element is not yet present in the DOM, a locate function will raise an ElementNotVisibleException exception.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is where wait comes into the picture to resolve this issue.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There are two types of wait:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Implicit wait&lt;/li&gt;
&lt;li&gt;Explicit Wait&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;An implicit wait tells WebDriver to poll the DOM for a certain amount of time when trying to find any element (or elements) not immediately available. The default setting is 0 (zero). Once set, the implicit wait is set for the life of the WebDriver object.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;

&lt;span class="n"&gt;driver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Firefox&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;implicitly_wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# seconds
&lt;/span&gt;
&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"http://somedomain/url_that_delays_loading"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;myDynamicElement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_element_by_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"myDynamicElement"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;An explicit wait is a code you define to wait for a certain condition to occur before proceeding further in the code. WebDriverWait in combination with ExpectedCondition is one way this can be accomplished.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium.webdriver.common.by&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;By&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium.webdriver.support.wait&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;WebDriverWait&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;selenium.webdriver.support&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;expected_conditions&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;EC&lt;/span&gt;

&lt;span class="n"&gt;driver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Firefox&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"http://somedomain/url_that_delays_loading"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebDriverWait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;until&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;EC&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;presence_of_element_located&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"myDynamicElement"&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;/li&gt;
&lt;li&gt;&lt;p&gt;In the code above, Selenium will wait for a maximum of 10 seconds for an element matching the given criteria to be found. If no element is found in that time, a TimeoutException is thrown. By default, WebDriverWait calls the ExpectedCondition every 500 milliseconds until it returns success. ExpectedCondition will return true (Boolean) in case of success or not null if it fails to locate an element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As we are moving towards the end of this post, you need to close the browser.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Closes the current session
&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Closes all the session
&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;quit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;This is not the end of selenium. There are various other resources to know about selenium.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;The above content provided is solely based on getting a basic understanding of selenium.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;For more details see the references sections.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  References:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://selenium-by-arun.blogspot.com/2017/05/history-of-selenium.html"&gt;How selenium came to existence?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To know more about selenium, read the below documentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.selenium.dev/documentation/overview/"&gt;Selenium&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://selenium-python.readthedocs.io/installation.html"&gt;Selenium with python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;To know more about &lt;a href="https://pypi.org/project/webdriver-manager/"&gt;Webdriver-manager&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;


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

</description>
      <category>python</category>
      <category>selenium</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Basics On HTML &amp; CSS</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Thu, 02 Mar 2023 09:25:02 +0000</pubDate>
      <link>https://dev.to/roshansahurk/basics-on-html-css-4222</link>
      <guid>https://dev.to/roshansahurk/basics-on-html-css-4222</guid>
      <description>&lt;ul&gt;
&lt;li&gt;This article includes a topic based on HTML and CSS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Box Model
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The box model is a concept in web development that defines how elements on a web page are structured and how their size and position are calculated.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Every HTML element is represented as a rectangular box, which consists of four parts: content, padding, border, and margin.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Content&lt;/strong&gt;: Content is the actual information or media that the element contains, such as text, images, or videos. &lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Padding&lt;/strong&gt;: The padding is the space between the content and the border, and it can be used to add extra spacing around the content.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.lilengine.co%2Fsites%2Fdefault%2Ffiles%2Finline-images%2FScreen%2520Shot%25202019-04-14%2520at%252023.59.07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.lilengine.co%2Fsites%2Fdefault%2Ffiles%2Finline-images%2FScreen%2520Shot%25202019-04-14%2520at%252023.59.07.png" alt="Image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Border&lt;/strong&gt;: The border is a line that surrounds the padding, and it can be styled with different colours, widths, and styles.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Margin&lt;/strong&gt;: The margin is the space between the border and the neighbouring elements, and it can be used to create gaps between elements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Together, these four parts of the box model determine the total size of the element.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The total size of the element is then calculated by adding the size of the content, padding, border, and margin.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  Inline versus Block Elements
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Elements can be classified into two main categories: &lt;em&gt;Inline and block&lt;/em&gt; elements. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The distinction between these two types of elements affects how they are rendered on the web page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Block elements&lt;/strong&gt;The elements that take up the entire width of their parent container and create a new line after the element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Examples of block elements include headings, paragraphs, lists, and divs.&lt;/li&gt;
&lt;li&gt;These elements are often used for larger pieces of content that require their own space on the page. &lt;/li&gt;
&lt;li&gt;They can also be styled using CSS to adjust their dimensions, margin, and padding.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Examples of block elements are&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;                       &lt;span class="c"&gt;/*Syntax for divisions*/&lt;/span&gt; 
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt;           &lt;span class="c"&gt;/*Syntax for headings*/&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;                         &lt;span class="c"&gt;/*Syntax for paragraphs*/&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ol&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;            &lt;span class="c"&gt;/*Syntax for bullet points*/&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;table&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;tr&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;td&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;   &lt;span class="c"&gt;/*Syntax for table*/&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;form&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;   &lt;span class="c"&gt;/*Syntax to take input from user*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Inline elements&lt;/strong&gt;: - The elements that do not create a new line after them and only take up as much width as their content requires.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inline elements include text, images, and links. &lt;/li&gt;
&lt;li&gt;These elements are often used for smaller pieces of content that need to be integrated into a larger block element. &lt;/li&gt;
&lt;li&gt;Inline elements can also be styled using CSS, but their width, margin, and padding properties may not behave in the same way as they do for block elements.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Examples of inline elements are&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;                  &lt;span class="c"&gt;/*Syntax for span*/&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;                     &lt;span class="c"&gt;/*Syntax for anchor*/&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;                   &lt;span class="c"&gt;/*Syntax for image*/&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;strong&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;em&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;     &lt;span class="c"&gt;/*Syntax for different styling in a text*/&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;br&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;                    &lt;span class="c"&gt;/*Syntax to break lines*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The choice of whether to use a block or inline element depends on the context and purpose of the content. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;For example, headings and paragraphs are typically block elements because they require their own space and are often used to separate content. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Meanwhile, links and images are typically inline elements because they are usually embedded within larger blocks of text or other content.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;In summary, block and inline elements differ in size, layout, and behaviour on the page. Understanding the difference between these two types of elements is important when designing and styling web pages.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Positioning in CSS refers to the process of placing an HTML element precisely in a particular position on a webpage. &lt;/li&gt;
&lt;li&gt;It can be used to adjust the location of an element on the page, as well as to layer elements on top of each other.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There are several types of positioning in CSS, But we will discuss Relative and Absolute positioning in this section:&lt;/p&gt;
&lt;h2&gt;
  
  
  Relative Positioning:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Relative positioning&lt;/strong&gt; is a type of positioning in CSS that allows you to position an element relative to its normal position. &lt;/li&gt;
&lt;li&gt;With relative positioning, you can move an element away from its default position, either by shifting it left, right, up or down or by a combination of these movements.&lt;/li&gt;
&lt;li&gt;When an element is positioned relatively, its position is calculated based on its original position in the document flow. This means that if you move a relatively positioned element, the other elements on the page will still flow around it as if it were still in its original position.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NOTE&lt;/strong&gt; - When you use relative positioning, the element still takes up the same amount of space as it would in its original position, so it may overlap other elements on the page if it is moved too far.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Absolute positioning&lt;/strong&gt; is a CSS property used to position an element in a specific location relative to its nearest positioned ancestor. &lt;/li&gt;
&lt;li&gt;When an element is positioned absolutely, it is removed from the normal flow of the document and does not affect the position of other elements on the page.&lt;/li&gt;
&lt;li&gt;To use absolute positioning, the parent element must have a position property set to either relative, absolute or fixed. The positioned element is then positioned concerning its parent element's top, right, bottom and left properties.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Note&lt;/strong&gt;: When using absolute positioning is that the position of the element is fixed relative to its nearest positioned ancestor, which means that if the parent element is not positioned, the element will be positioned relative to the body element.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Here is an example of how to use absolute positioning:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- HTML FILE --&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;"parent"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"child"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```css
&amp;lt;!-- CSS FILE  --&amp;gt;
.parent {
position: relative;
width: 200px;
height: 300px;
background-color: gray;
}

.child {
position: absolute;
top: 50px;
left: 50px;
width: 100px;
height: 100px;
background-color: red;
}```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;CSS class selectors are used to apply special styles to an element in certain circumstances or states. &lt;/li&gt;
&lt;li&gt;&lt;p&gt;They allow developers to target elements based on their state or position in the document, without using JavaScript or adding extra HTML markup.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Some common CSS pseudo-class selectors include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;:first-child&lt;/strong&gt; - selects the first child element of the parent element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;:last-child&lt;/strong&gt; - selects the last child element of the parent element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;:nth-child&lt;/strong&gt; - selects a specific child element based on its position in the parent element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;:hover&lt;/strong&gt; - applies a style when the mouse pointer is over the element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;:active&lt;/strong&gt; - applies a style when the element is being activated (e.g., clicked).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;:focus&lt;/strong&gt; - applies a style when the element has focus (e.g., when it is selected by keyboard navigation).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;:checked&lt;/strong&gt; - applies a style to an element that is checked, such as a checkbox or radio button.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;:disabled&lt;/strong&gt; - applies a style to an element that is disabled, such as an input field or button.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;By applying different styles to elements based on their state or position, developers can provide visual feedback to users and guide them through the interface.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Common CSS styling classes are pre-defined classes used to apply specific styling to elements in HTML. These classes allow developers to quickly and easily apply common styles to elements on their web pages without having to write custom CSS code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Some examples of common CSS styling classes include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Text styling classes&lt;/strong&gt;: These classes allow developers to change the font size, colour, weight, and other text properties. Examples include .text-bold, .text-italic, .text-underline, and .text-uppercase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Margin and padding classes&lt;/strong&gt;: These classes control the spacing around elements on a web page. Examples include .m-0 (margin set to 0), .m-1 (margin set to 1rem), .p-0 (padding set to 0), and .p-1 (padding set to 1rem).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Border classes&lt;/strong&gt;: These classes allow developers to add borders to elements on a web page. Examples include .border, .border-top, .border-bottom, and .border-radius.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background colour classes&lt;/strong&gt;: These classes allow developers to set the background colour of elements on a web page. Examples include .bg-primary, .bg-secondary, and .bg-dark.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexbox classes&lt;/strong&gt;: These classes allow developers to use the CSS Flexbox layout model to position elements on a web page. Examples include .d-flex, .justify-content-center, and .align-items-center.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Responsive classes&lt;/strong&gt;: These classes allow developers to apply different styles to elements based on the size of the device being used to view the web page. Examples include .d-sm-block (display as a block on small screens and above), .d-md-flex (display as flex on medium screens and above), and .hidden-lg-up (hide on large screens and above).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;By using common CSS styling classes, developers can save time and effort when styling their web pages, while also ensuring a consistent look and feel across their site.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  CSS Specificity
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CSS specificity&lt;/strong&gt; is a set of rules that determine which styles will be applied to an element when multiple style rules are targeting the same element. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is a measure of the weight of a CSS selector, and it determines which rule will be applied if two or more selectors target the same element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CSS specificity is calculated based on the combination of the different selector types used in the style rule. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each selector type has a specific value, and the values are added together to determine the specificity of the selector.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The different selector types, in order of increasing specificity, are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Type selectors (e.g., p, div, span)&lt;/li&gt;
&lt;li&gt;Class selectors (e.g., .class-name)&lt;/li&gt;
&lt;li&gt;ID selectors (e.g., #id-name)&lt;/li&gt;
&lt;li&gt;Inline styles (e.g., style="colour: red;")&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The specificity of a selector can be represented as a four-digit number. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The first digit represents the number of ID selectors, the second digit represents the number of class selectors and attribute selectors, the third digit represents the number of type selectors, and the fourth digit represents the number of pseudo-classes and pseudo-elements.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;For example, the selector #header .logo has a specificity of 110, because it has one ID selector and one class selector. On the other hand, the selector body .logo has a specificity of 010, because it has one class selector and one type selector.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;When multiple style rules apply to an element, the browser applies the style rule with the highest specificity. If two or more style rules have the same specificity, the browser applies the style rule that comes last in the CSS file or the HTML document.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;It is important to keep in mind the specificity of selectors when writing CSS, to avoid unexpected styling behaviour and to ensure that the desired styles are applied to the elements. It is also important to avoid using too many ID selectors, as they have high specificity and can lead to specificity wars and difficult-to-maintain CSS code.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CSS responsive queries&lt;/strong&gt; allow developers to create responsive websites that adjust to different screen sizes and devices. These queries use CSS media queries to apply specific styles based on the device's screen size.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For example, a responsive query may specify that if the screen size is smaller than 768 pixels, the font size should be reduced and the navigation menu should be collapsed. Alternatively, if the screen size is larger than 1200 pixels, the layout should be adjusted to accommodate more content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To implement responsive queries, developers typically define a set of breakpoints based on common screen sizes, such as 320px for mobile devices, 768px for tablets, and 1200px for desktops. They can then apply styles based on these breakpoints using media queries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The following code applies a style to all elements with the class "content" when the screen width is less than 768 pixels:&lt;br&gt;
&lt;/p&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="nc"&gt;.content&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By using responsive queries, developers can ensure that their websites are optimized for different devices and provide a consistent user experience across all screen sizes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Flexbox/Grid
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexbox&lt;/strong&gt; and &lt;strong&gt;Grid&lt;/strong&gt; are two powerful tools in CSS that allow developers to create complex and responsive layouts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Flexbox&lt;/strong&gt; is a one-dimensional layout system that is best suited for arranging items along a single row or column. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It consists of a container element and one or more child elements, or flex items. &lt;/li&gt;
&lt;li&gt;The container element is defined using the display: flex property and the child elements can be aligned and positioned using a range of flex properties, such as justify-content and align-items. &lt;/li&gt;
&lt;li&gt;Flexbox is great for creating navigation menus, form layouts, and other simple layouts.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Grid&lt;/strong&gt; is a two-dimensional layout system that allows developers to create grid layouts that are highly responsive and dynamic. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Grid consists of a container element and a set of grid items that are arranged in rows and columns. &lt;/li&gt;
&lt;li&gt;Grid can be used to create complex layouts that include multiple rows, columns, and nested grids. &lt;/li&gt;
&lt;li&gt;Grid also includes a range of properties that allow developers to control the sizing, positioning, and alignment of grid items.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;In general, Flexbox is best suited for simple layouts that require alignment along a single axis, while Grid is better suited for complex layouts that require alignment along two axes. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;However, both Flexbox and Grid are highly flexible and can be used in combination to create even more complex layouts.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Common header meta tags are used to provide metadata information about an HTML document. &lt;/li&gt;
&lt;li&gt;These tags are placed in the head section of an HTML document and help search engines and other applications understand the content and purpose of the page. &lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Here are some common header meta tags:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/*1.*/&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;title&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;title&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/*2.*/&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;meta&lt;/span&gt; &lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"description"&lt;/span&gt; &lt;span class="nt"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"description of the page"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/*3.*/&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;meta&lt;/span&gt; &lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"keywords"&lt;/span&gt; &lt;span class="nt"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"comma-separated list of keywords"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/*4.*/&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;meta&lt;/span&gt; &lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"viewport"&lt;/span&gt; &lt;span class="nt"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/*5.*/&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;meta&lt;/span&gt; &lt;span class="nt"&gt;http-equiv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"refresh"&lt;/span&gt; &lt;span class="nt"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"5;url=redirect-url"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Title tag: - This tag is used to define the title of the document. It is displayed in the title bar of the browser and is also used by search engines to understand the content of the page.

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Description tag: This tag is used to provide a brief description of the page's content. Search engines often use this description to display a summary of the page in search results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keyword tag: This tag is used to specify a list of keywords that are relevant to the content of the page. Search engines use this information to help rank the page in search results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Viewport tag: This tag is used to specify the viewport size of the page for mobile devices. It ensures that the page is displayed properly on devices with different screen sizes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redirection tag: This tag is used to automatically redirect the page to another URL after a specified time. The number after "content=" specifies the number of seconds before the redirect occurs, and "url=" specifies the URL to redirect to.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/code&gt;&lt;/pre&gt;

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


&lt;ul&gt;
&lt;li&gt;For more details, click on the below:

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model" rel="noopener noreferrer"&gt;Box-Model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/difference-between-block-elements-and-inline-elements/" rel="noopener noreferrer"&gt;Inline Vs Block Elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.web4college.com/css/web4-css-structural-classes.php" rel="noopener noreferrer"&gt;CSS structural classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors" rel="noopener noreferrer"&gt;CSS styling classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity" rel="noopener noreferrer"&gt;CSS Specificity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/a-complete-guide-to-css-media-queries/" rel="noopener noreferrer"&gt;CSS Responsive Queries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/" rel="noopener noreferrer"&gt;Flex-box&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/snippets/css/complete-guide-grid/" rel="noopener noreferrer"&gt;Grid&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ionos.com/digitalguide/websites/web-development/the-most-important-meta-tags-and-their-functions/" rel="noopener noreferrer"&gt;Common header meta tags&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>General Questions</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Thu, 02 Mar 2023 06:36:33 +0000</pubDate>
      <link>https://dev.to/roshansahurk/general-questions-5emh</link>
      <guid>https://dev.to/roshansahurk/general-questions-5emh</guid>
      <description>&lt;p&gt;This section covers the general questions on Cli, Git, Python, Html and CSS.&lt;/p&gt;

&lt;h1&gt;
  
  
  Q1. How do you delete a specific stash in git?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You can delete a specific stash in git by the command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git stash drop stash@&lt;span class="o"&gt;{&lt;/span&gt;n&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This command will permanently delete the stash.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Where n is the index number of the stash.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The indexing of the stash from 0 and goes on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To search for a specific index in the stash, use the command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git stash list
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h1&gt;
  
  
  Q2. Why do we use "transform: translate" in CSS? Which browser doesn't support this CSS property?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;transform: translate()&lt;/strong&gt; property in CSS is used to move an element from its original position in the horizontal and/or vertical direction.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Q3. What is the difference between a "terminal" and a "console" in the context of Linux?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Terminal&lt;/strong&gt;: A terminal is a program that provides a user interface to access the shell, which is the command-line interface of the operating system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Console&lt;/strong&gt;: The console is the physical device or interface that allows you to interact with the system directly without any graphical interface.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Q4. What is the difference between "grep" and "find" commands in Linux?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Grep&lt;/strong&gt;: The grep command is used to search for specific text patterns within files. It can search for a single pattern or multiple patterns using regular expressions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Find&lt;/strong&gt;: The find command is used to search for files and directories based on certain criteria, such as file name, date modified, or file type. It can also perform actions on the files found, such as copying, moving, or deleting them.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Q5. If there are 3 items in a row, how do you position the item in the third column to the first column using a grid?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You can use the below command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;grid-column&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="err"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;grid-column&lt;/strong&gt; used in grid layouts to define both the start and end positions of a grid item within a grid column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It accepts two values: the starting grid line and the ending grid line for the item in the column axis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This command will set the 3 items in a row to the first column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As an alternative to the above command you can also use the below command.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;grid-column-start&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="err"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;grid-column-start&lt;/strong&gt; is a CSS property used in grid layouts to define the start position of a grid item within a grid column.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Q6. How can you slice a list in Python?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The word slice means to get a specific piece of an object. In python, slicing presents the specified part of the object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To put it in more simple words. Here is an example in python:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'abcd'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'hello'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;68&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'hello'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The syntax for slicing is:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;object-name[start:end:step]     
&lt;/code&gt;&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Start&lt;/strong&gt;: Specify the index where you want to start.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;End&lt;/strong&gt;: Specify the index up to the required end.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step&lt;/strong&gt;: Specify if you want to skip the slice in steps.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h1&gt;
  
  
  Q7. Why do we need the concept of transactions in SQL? What does it help us to achieve?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Transaction&lt;/strong&gt; is a sequence of operations performed on a database that is considered to be a single logical unit of work. Transactions can consist of one or more database operations, such as inserting, updating, or deleting records. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transactions are needed in a database system to ensure data consistency and integrity. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When multiple operations need to be performed together, such as transferring funds from one bank account to another, it is essential to ensure that either all the operations succeed, or none of them does. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Without transactions, a failure in the middle of such operations could leave the database in an inconsistent state, causing data corruption and loss.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To avoid data corruption and loss, transactions are used.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Q8. What is the use of an iframe tag?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An iframe is an HTML element used to embed another HTML document inside the current document. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The Syntax to use the iframe tag is:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;iframe&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"URL"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h1&gt;
  
  
  Q9. What is the difference between a descendant and a child selector?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A descendant selector is used to select all elements that are descendants of a specified parent element, regardless of how many levels down the hierarchy they are.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c"&gt;/* CSS rules go here */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A child selector, on the other hand, only selects direct children of a specified parent element. It uses the &amp;gt; symbol to separate the parent and child elements in the selector.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c"&gt;/* CSS rules go here */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h1&gt;
  
  
  Q.10 What is the difference between discard() and remove() in Python?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;discard()&lt;/strong&gt; and &lt;strong&gt;remove()&lt;/strong&gt; method removes the specified item in a set.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The major key difference is discard method doesn't throw an error when the specified key is not present not in the set but the remove method throws an error when the specified key is not present in the set.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ADD-ONS&lt;/strong&gt;: You will find a similar explanation for some similar commands in the list and dictionary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Q.11 Can you join a table with itself and if so how?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Yes, a table can be joined with itself, and this is known as a &lt;strong&gt;SELF JOIN&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;A self-join is useful when a table contains a foreign key that references its primary key. &lt;/li&gt;
&lt;li&gt;You can also use &lt;strong&gt;INNER JOIN&lt;/strong&gt; with a different alias to join the table with itself or use sub-queries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Q.12 What is the difference between a view and a temporary table in SQL?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A view and a temporary table are both database objects, but they serve different purposes and have different characteristics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A view is a virtual table that is based on the result of a SQL query. It is not a physical table and does not store data itself, but instead retrieves and displays data from one or more underlying tables. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A temporary table is a physical table that is created and used for a specific session or transaction. Temporary tables are usually created for the temporary storage of data that is only needed for a short period.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Temporary tables are not stored permanently in the database and are automatically deleted at the end of the session or transaction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In summary, views are virtual tables that provide a simplified interface to the data, while temporary tables are physical tables that are used for the temporary storage of data during a session or transaction.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Q13. What is the z-index property in CSS?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The z-index property in CSS is used to control the vertical stacking order of elements on a web page. &lt;/li&gt;
&lt;li&gt;It specifies the stack order of an element relative to other elements on the page. &lt;/li&gt;
&lt;li&gt;Elements with a higher z-index value are displayed on top of elements with a lower z-index value.&lt;/li&gt;
&lt;li&gt;The z-index property can be applied to any positioned element (position: absolute, position: relative, position: fixed, or position: sticky).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>sql</category>
      <category>python</category>
      <category>git</category>
      <category>programming</category>
    </item>
    <item>
      <title>SQL Concepts</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Wed, 22 Feb 2023 06:59:33 +0000</pubDate>
      <link>https://dev.to/roshansahurk/sql-concepts-1o4a</link>
      <guid>https://dev.to/roshansahurk/sql-concepts-1o4a</guid>
      <description>&lt;p&gt;This paper gives an outlook about SQL Concepts and Database .&lt;br&gt;
The concepts discussed in the paper includes ACID, CAP, JOINS, AGGREGATION FILTERS IN QUERIES, NORMALIZATION, INDEXES, LOCKING MECHANISM, DATABASE ISOLATION LEVELS AND TRIGGERS.  &lt;/p&gt;
&lt;h1&gt;
  
  
  &lt;strong&gt;ACID&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The acronym for &lt;strong&gt;ACID&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A - &lt;strong&gt;A&lt;/strong&gt;tomicity&lt;/li&gt;
&lt;li&gt;C - &lt;strong&gt;C&lt;/strong&gt;onsistency &lt;/li&gt;
&lt;li&gt;I - &lt;strong&gt;I&lt;/strong&gt;solation&lt;/li&gt;
&lt;li&gt;D - &lt;strong&gt;D&lt;/strong&gt;urability &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Before diving into the &lt;strong&gt;ACID&lt;/strong&gt;, we must first see what are transaction.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Transaction&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A single task is the smallest unit of processing that cannot be divided any further. The set of tasks collectively is referred to as transactions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A transaction typically involves one or more database operations, such as inserting, updating, or deleting records in one or more tables. All of these operations are executed as a single unit of work, either all succeeding or all failing, and are usually wrapped in a &lt;strong&gt;BEGIN TRANSACTION&lt;/strong&gt; and &lt;strong&gt;COMMIT TRANSACTION&lt;/strong&gt; statement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If an error occurs during the transaction, the changes made so far can be rolled back or undone, using a &lt;strong&gt;ROLLBACK TRANSACTION&lt;/strong&gt; statement. This ensures that the database remains in a consistent state and prevents data corruption or loss.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transactions can also harm performance since they require additional resources and can result in the locking and blocking of data. Therefore, it is important to use transactions judiciously and optimize them for maximum efficiency.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Atomicity&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The principle of atomicity is commonly referred to as the 'All or nothing rule', which means that a transaction must be executed entirely or not at all.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If an action is performed on a transaction there are only two possible outcomes whether there is complete execution or the execution is not successful.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It involves the following two operations.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Abort&lt;/strong&gt; - Changes made to the database are invisible if a transaction aborts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commit&lt;/strong&gt; - Changes are shown after a transaction commits.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Atomicity is also known as the &lt;strong&gt;'All or nothing rule'.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Consistency&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consistency&lt;/strong&gt; refers to the idea that the value must constantly be maintained and the correctness of the data.&lt;/li&gt;
&lt;li&gt;For example, Bank statements

&lt;ul&gt;
&lt;li&gt;Banks maintain consistent rules to avoid any mishappenings.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;To maintain consistency in the database, integrity constraints must be enforced before and after each transaction.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Isolation&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It is not necessary that at a time only one transaction would happen.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What if there are numerous transactions? The consistency may break which defeats the whole purpose of being consistent in the database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Isolation&lt;/strong&gt; guarantees that numerous transactions can take place simultaneously without changing the database state to become inconsistent. Transactions take place without interruption and independently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transactions are isolated from each other to ensure that any changes made to data in one transaction are not visible to other transactions until they are committed to the database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This property ensures that the execution of transactions concurrently will result in a state that is equivalent to a state achieved these were executed serially in some order. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Durability&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Durability&lt;/strong&gt; refers that data remaining in the database permanently once an operation has been completed.&lt;/li&gt;
&lt;li&gt;Data should be durable so that in case of system failure, malfunctions or crash, it can still function.&lt;/li&gt;
&lt;li&gt;However, if the data disappears, the recovery manager is now in charge, to ensure that the data remains safe.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  &lt;strong&gt;CAP Theorem&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;CAP&lt;/strong&gt; stands for &lt;em&gt;**C&lt;/em&gt;&lt;em&gt;onsistency&lt;/em&gt;, &lt;em&gt;**A&lt;/em&gt;&lt;em&gt;vailability&lt;/em&gt; and &lt;em&gt;**P&lt;/em&gt;&lt;em&gt;artition Tolerance.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consistency&lt;/strong&gt; - Consistency means that every read gets the most recent write or an error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Availability&lt;/strong&gt; - Availability means that every request receives a response without guaranteeing that it contains the most recent write.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partition Tolerance&lt;/strong&gt; - Partition Tolerance means that the system continues to function despite messages being dropped or delayed between nodes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The CAP theorem states that a distributed data store can provide only two of the following three guarantees: consistency, availability, and partition tolerance. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sometimes, all three can be provided, but at other times, there may be trade-offs between these guarantees.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Consistency comes at the expense of availability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Availability comes at the expense of consistency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When responding to a query, a highly available service may provide the current value on the server, but there is no guarantee that it is the most recent value submitted to the database due to potential delays in transit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To ensure high consistency, we must wait for the new write or return an error to the query. This means sacrificing availability to ensure the data returned by the query is consistent.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  &lt;strong&gt;Joins&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Join&lt;/strong&gt; statement is used in SQL to join two or more rows/columns to the table.&lt;/li&gt;
&lt;li&gt;The different type of join are &lt;strong&gt;INNER JOIN&lt;/strong&gt;, &lt;strong&gt;LEFT JOIN&lt;/strong&gt;, &lt;strong&gt;RIGHT JOIN&lt;/strong&gt; and &lt;strong&gt;FULL OUTER JOIN&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SQL is case-insensitive. To differentiate SQL queries, uppercase has been used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;INNER JOIN&lt;/strong&gt; - It returns only the matching records from both tables based on the condition provided in the &lt;strong&gt;ON&lt;/strong&gt; clause.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;LEFT JOIN&lt;/strong&gt; - It returns all the records from the left table and matching records from the right table. If there are no matching records in the right table, it returns &lt;strong&gt;NULL&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;RIGHT JOIN&lt;/strong&gt; - It returns all the records from the right table and matching records from the left table. If there are no matching records in the left table, it returns &lt;strong&gt;NULL&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;
&lt;span class="k"&gt;RIGHT&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;FULL OUTER JOIN&lt;/strong&gt; - It returns all the records from both tables and matching records where they exist. If there are no matching records in either table, it returns &lt;strong&gt;NULL&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;
&lt;span class="k"&gt;FULL&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; - Here table1 and table2 refers to the name of the table. The name of the table varies from database to database. The same applies to the column also.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Aggregations, Filters in Queries&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Aggregate&lt;/strong&gt; function in SQL returns one value after calculating multiple values in a column.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Various types of Aggregate functions are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;SUM(arg)&lt;/strong&gt; - The sum function returns the total sum of the column.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;column_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;column_name2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;COUNT(arg)&lt;/strong&gt; - The count function returns the total number of occurrences in the column.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;COUNT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;column_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AVG(arg)&lt;/strong&gt; - Average function calculates the average of the set of values.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;column_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;column_name2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;MIN(arg)&lt;/strong&gt; - The Min function returns the minimum value available in the column.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;MIN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;column_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;column_name2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;MAX(arg)&lt;/strong&gt; - Max function returns the maximum value available in the column.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;column_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;column_name2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Filters&lt;/strong&gt; are text strings that we use to specify a subset of the data items in the given conditions.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;In the above example filters have been used.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;WHERE&lt;/strong&gt; is the filter used in the above queries&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CONDITION1&lt;/span&gt; &lt;span class="k"&gt;OR&lt;/span&gt; &lt;span class="n"&gt;CONDITION2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;&lt;p&gt;More than one condition can be put through the where statement to filter the data in the database.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Normalization&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Normalization&lt;/strong&gt; is the process of restructuring a relational database by a series of so-called normal forms to reduce data redundancy and improve data integrity.&lt;/li&gt;
&lt;li&gt;If you have a messy database or unintentionally synthesized one with poor integrity, then database normalization is the solution for you. &lt;/li&gt;
&lt;li&gt;Large tables can be divided into smaller tables through the process of normalization.&lt;/li&gt;
&lt;li&gt;The goal is to minimize data duplication and eliminate data inconsistencies.&lt;/li&gt;
&lt;li&gt;Normalization principles can design efficient and robust databases that are easier to maintain and update.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There are different levels of normalization ranging from the first normal form &lt;strong&gt;(1NF)&lt;/strong&gt; to the fifth normal form &lt;strong&gt;(5NF).&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1NF&lt;/strong&gt; requires that each column in a table contains indivisible values. Each column must have a unique name and no two rows in the table can be identical.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2NF&lt;/strong&gt; requires that the table is in 1NF and that each non-key column in the table is dependent on the entire primary key, not just part of it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3NF&lt;/strong&gt; requires that the table is in 2NF and that there are no non-key columns that are dependent on other non-key columns. Specifically, in normalization, non-key columns should only depend on the primary key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;4NF&lt;/strong&gt; requires that the table is in BCNF and that there are no multi-valued dependencies (when a table has multiple independent relationships with another table).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;5NF&lt;/strong&gt; requires that the table is in 4NF and that it does not have any lossless decomposition. In other words, it should not be possible to combine two tables and get the original table without losing any information.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Indexes&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Indexes&lt;/strong&gt; is used to improve the performance of queries by providing quick access to data. Indexes load the data quickly instead of loading data.&lt;/li&gt;
&lt;li&gt;They can be created on one or more columns and can be created as unique or non-unique.&lt;/li&gt;
&lt;li&gt;A unique index ensures that each value in the indexed value is unique.&lt;/li&gt;
&lt;li&gt;A non-unique index can have duplicate values.&lt;/li&gt;
&lt;li&gt;When a query is executed, the database engine uses the index to quickly locate the relevant rows, reducing the time and resources needed to retrieve data.&lt;/li&gt;
&lt;li&gt;The only disadvantage is that they take up storage space and require additional processing time to maintain as data is inserted, updated and deleted.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Locking Mechanism&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Locking&lt;/strong&gt; is a mechanism used by databases to manage concurrent access to data by multiple users or processes. &lt;/li&gt;
&lt;li&gt;&lt;p&gt;It prevents conflicts and ensures data integrity by allowing only one user or process to modify a piece of data at a time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There are two types of locks: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Shared locks&lt;/strong&gt; - These allow multiple users to read a piece of data simultaneously.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exclusive locks&lt;/strong&gt; - It allows only one user to modify the data at a time.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;When a user attempts to modify a piece of data, the database will first obtain an exclusive lock on the data to ensure that no other user is modifying it at the same time. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Upon committing or rolling back a transaction, the lock is released.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Locking can impact database performance since it requires additional resources and can result in the blocking of data.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Database isolation levels&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Database isolation levels&lt;/strong&gt; are a set of rules that determine how transactions interact with one another in a multi-user database environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The isolation level determines how concurrent transactions can access and modify the same data, and how changes made by one transaction are visible to others.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There are four commonly used isolation levels in databases: &lt;em&gt;Read Uncommitted&lt;/em&gt;, &lt;em&gt;Read Committed&lt;/em&gt;, &lt;em&gt;Repeatable Read&lt;/em&gt;, and &lt;em&gt;Serializable&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Read Uncommitted&lt;/strong&gt; - The Read Uncommitted isolation level allows transactions to read uncommitted data, which means a transaction can read data modified by another uncommitted transaction. 

&lt;ul&gt;
&lt;li&gt;The highest level of concurrency.&lt;/li&gt;
&lt;li&gt;The lowest level of data consistency.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Read Committed&lt;/strong&gt; - The Read Committed isolation level ensures that a transaction reads only committed data, which means a transaction will not read data modified by another uncommitted transaction. 

&lt;ul&gt;
&lt;li&gt;A higher level of consistency than Read Uncommitted, but comes with reduced concurrency.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Repeatable Read&lt;/strong&gt; - The Repeatable Read isolation level ensures that a transaction reads the same set of data throughout its lifetime, even if other transactions modify the data in the meantime. 

&lt;ul&gt;
&lt;li&gt;A higher level of consistency than Read Committed, but reduces concurrency even further.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Serializable&lt;/strong&gt; - The Serializable isolation level provides the highest level of consistency, ensuring that transactions execute in a serializable order and that all transactions are isolated from one another. 

&lt;ul&gt;
&lt;li&gt;Strongest guarantees of data consistency, but also the lowest level of concurrency.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Choosing the appropriate isolation level depends on the specific requirements of the application.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  Triggers
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Triggers&lt;/strong&gt; are database objects that are used to automatically execute a set of SQL statements in response to certain database events or data changes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They can be used to enforce business rules, audit data changes, maintain referential integrity, and perform other automated tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Triggers are typically defined to execute in response to one of the following events: &lt;strong&gt;INSERT&lt;/strong&gt;, &lt;strong&gt;UPDATE&lt;/strong&gt;, or &lt;strong&gt;DELETE&lt;/strong&gt;. They can be defined to execute either before or after the triggering event occurs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Triggers can be defined at either the table level or the database level and can be used to enforce complex business rules and data validation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;While triggers can be powerful tools for enforcing data integrity and automating tasks, they can also have an impact on database performance if they are not used appropriately. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;To know more about the topics discussed above, you can click on the below links.

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/acid-properties-in-dbms/" rel="noopener noreferrer"&gt;ACID Properties&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/CAP_theorem" rel="noopener noreferrer"&gt;CAP Theorem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.scaler.com/topics/sql/joins-in-sql/" rel="noopener noreferrer"&gt;Join statement in SQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.simplilearn.com/tutorials/sql-tutorial/what-is-normalization-in-sql#:~:text=Normalization%20is%20the%20process%20to,data%20from%20the%20relational%20tables." rel="noopener noreferrer"&gt;Normalization&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sqlshack.com/sql-index-overview-and-strategy/" rel="noopener noreferrer"&gt;Indexes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sqlshack.com/transactions-in-sql-server-for-beginners/" rel="noopener noreferrer"&gt;Transactions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codingsight.com/main-concept-of-sql-server-locking/" rel="noopener noreferrer"&gt;Locking Mechanism&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sqlservercentral.com/articles/isolation-levels-in-sql-server" rel="noopener noreferrer"&gt;Database Isolation levels&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sqlshack.com/learn-sql-sql-triggers/" rel="noopener noreferrer"&gt;Triggers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>suricata</category>
      <category>infosec</category>
      <category>security</category>
      <category>network</category>
    </item>
    <item>
      <title>SOLID Concepts</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Mon, 20 Feb 2023 06:38:08 +0000</pubDate>
      <link>https://dev.to/roshansahurk/solid-1jjl</link>
      <guid>https://dev.to/roshansahurk/solid-1jjl</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Solid is a principle that is written in conjunction with code to improve the problems of bad code which are rigidity, fragility and non-usability. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Implementing the solid principle into the code helps the programmer to easily add the changes required onto the code with lesser effort.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Solid?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In the world of software development, programmers tend to tangle up while making changes in the code. &lt;/li&gt;
&lt;li&gt;A good programmer writes readable, clear and concise code.&lt;/li&gt;
&lt;li&gt;Even if the quality of the code is good, the programmer could find it hard to make some changes to it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why solid should be used?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To understand this let us look at the below example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A bank company hires a programmer to make software which stores the credential id and could only be accessed by the customer.&lt;/li&gt;
&lt;li&gt;The programmer makes the software and hands it over to the bank company.&lt;/li&gt;
&lt;li&gt;After using it for a while, the bank company asks the programmer for some changes to it.&lt;/li&gt;
&lt;li&gt;The programmer looks up to the code and do the changes required.&lt;/li&gt;
&lt;li&gt;The highest probability is that the software will crash if the quality of the code is bad.&lt;/li&gt;
&lt;li&gt;He has to make changes to the other modules as well.&lt;/li&gt;
&lt;li&gt;The bigger picture in the development field is that the programmer goes to such lengths for making those small changes.&lt;/li&gt;
&lt;li&gt;If we don't follow solid principles we end up with tight or strong coupling of the code with many other modules/applications.&lt;/li&gt;
&lt;li&gt;Tight coupling causes time to implement any new requirement, feature or bug fixes and sometimes it creates some unknown issues.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Therefore, to resolve such problems an American software engineer and instructor &lt;a href="https://en.wikipedia.org/wiki/Robert_C._Martin"&gt;Robert C. Martin&lt;/a&gt; came up with a solid principle.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Getting started with Solid&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The acronyms for class design principles in the solid are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;S&lt;/strong&gt;RP - Single Responsibility Principle&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;O&lt;/strong&gt;CP - Open Close Principle&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L&lt;/strong&gt;SP - Liskov Substitution Principle&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I&lt;/strong&gt;SP - Interface Segregation Principle&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;D&lt;/strong&gt;IP - Dependency Inversion Principle &lt;/li&gt;
&lt;/ul&gt;


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

&lt;h3&gt;
  
  
  &lt;strong&gt;Single Responsibility Principle&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"A class should have only one reason to change"&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each class and module focuses on a single task at a time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If a class has more than one responsibility, it becomes coupled.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vehicle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VehicleDB&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_vehicle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Vehicle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

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

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When designing our classes, we should aim to put related features together, so whenever they tend to change they change for the same reason. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Open Close Principle&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"Modules should be open for extension, but closed for modification."&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To understand more about the open-close principle let us take an example.&lt;/li&gt;
&lt;li&gt;Let’s imagine you have a store, and you give a discount of 20% to your favourite customers using this class.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When you decide to offer double the 20% discount to VIP customers. You may modify the class like this:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Discount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;give_discount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'fav'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'vip'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This fails the OCP principle due to the changes made in the module.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To make it follow the OCP principle, we will add a new class that will extend the Discount.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In this new class, we would implement its new behaviour.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Discount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_discount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VIPDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Discount&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_discount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;get_discount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You see, extension without modification.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Liskov Substitution Principle&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"Derived class must be usable through the base class interface, without the need for the user to know the difference."&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Liskov principle is a particular definition of a subtyping relation called behavioural subtyping.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The Liskov substitution principle can be implemented by the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No new exceptions can be thrown by the subtype.&lt;/li&gt;
&lt;li&gt;Clients should not know which specific subtype they are calling.&lt;/li&gt;
&lt;li&gt;New derived classes just extend without replacing the functionality of old classes.&lt;/li&gt;
&lt;li&gt;This principle aims to ascertain that a sub-class can assume the place of its super-class without errors.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;If the code finds itself checking the type of class then, it must have violated this principle.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;animal_leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;animal&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Lion&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lion_leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Mouse&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mouse_leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Pigeon&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pigeon_leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;animal_leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




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

&lt;p&gt;The above example does not follow liskov's principle, the following changes should be made to make it follow liskov's principle.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;animal_leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;animal&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;leg_count&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="n"&gt;animal_leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The animal_leg_count function cares less about the type of Animal passed, it just calls the leg_count method. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All it knows is that the parameter must be of an Animal type, either the Animal class or its sub-class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;The Animal class now have to implement/define a leg_count method and its sub-classes have to implement the leg_count method.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Lion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;leg_count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;&lt;p&gt;animal_leg_count just calls the leg_count method of the Animal type because by contract a sub-class of the Animal class must implement the leg_count function.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Interface Segregation Principle&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"No client should be forced to depend on the interface/methods it does not use."&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Classes should not have to implement interfaces with methods they don't need.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One large interface should be split into many smaller and relevant interfaces so that the clients can know about the interfaces that are relevant to them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Let’s look at the below IShape interface&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IShape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IShape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IShape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw_circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It’s quite funny looking at the code above. Class Rectangle implements methods (draw_circle and draw_square) it has no use of, likewise Square implements draw_circle, and draw_rectangle, and class Circle (draw_square, draw_rectangle).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The classes must implement the new method or an error will be thrown.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We see that it is impossible to implement a shape that can draw a circle but not a rectangle or a square or a triangle. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can just implement the methods to throw an error that shows the operation cannot be performed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clients (here Rectangle, Circle, and Square) should not be forced to depend on methods that they do not need or use. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To make our IShape interface conform to the ISP principle, we segregate the actions into different interfaces.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Classes (Circle, Rectangle, Square, Triangle, etc) can just inherit from the IShape interface and implement their draw behaviour.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;IShape&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IShape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IShape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IShape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can then use the I-interfaces to create Shape specifics like Semi Circle, Right-Angled Triangles, Equilateral Triangle, Blunt-Edged Rectangle, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Dependency Inversion Principle&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"High-level modules should not depend on low-level modules."&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Abstraction should not depend on details. Details should depend on abstraction.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The interaction between high-level and low-level modules should be thought of as an abstract interaction between them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There comes a point in software development where our app will be largely composed of modules. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When this happens, we have to clear things up by using dependency injection. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;High-level components depend on low-level components to function.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;XMLHttpService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;XMLHttpRequestService&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;xml_http_service&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;XMLHttpService&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xml_http_service&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;xml_http_service&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xml_http_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'GET'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xml_http_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Here, Http is the high-level component whereas HttpService is the low-level component. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This design violates DIP A: High-level modules should not depend on low-level level modules. It should depend upon its abstraction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This Http class is forced to depend upon the XMLHttpService class.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;XMLHttpService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Connection&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;xhr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;XMLHttpRequest&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;send&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NodeHttpService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Connection&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MockHttpService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Connection&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can create many Http Connection types and pass them to our Http class without any fuss about errors.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;In the field of software development, solid principles are used to achieve flexibility in the code.&lt;/li&gt;
&lt;li&gt;One can refactor their codes and revise it again and again very easily.&lt;/li&gt;
&lt;li&gt;Implementing the five key principles in the code maintains the reusability of code as well.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;To know more about solid refers to the below section

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/SOLID"&gt;Solid&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=TMuno5RZNeE"&gt;Solid principles by Bob Martin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.hashbangcode.com/article/solid-principles-python"&gt;Examples on the five principles&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


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

</description>
      <category>programming</category>
      <category>oop</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Object Oriented Programming</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Thu, 16 Feb 2023 07:40:37 +0000</pubDate>
      <link>https://dev.to/roshansahurk/object-oriented-programming-1e0c</link>
      <guid>https://dev.to/roshansahurk/object-oriented-programming-1e0c</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Solving a problem by creating objects is one of the most popular approaches in programming this is called object-oriented programming. The concept focuses on using reusable code that implements the dry principle.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Python can be used as a declarative modular programming language as well as being used for imperative programming or full object-oriented programming. Declarative programming is a paradigm in which we focus on what we want to implement. Imperative programming is where we describe the exact steps of how to implement what we want.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Class
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A class is a blueprint for how something should be defined it doesn't contain any data it is a template that is used to create instances as per the specifications defined in a template or a blueprint.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;    
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h2&gt;
  
  
  Object
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An object of a class is an instance that is built from a class and that is why it is also called an instance of a class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;An object is an instantiation of a class. When a class is defined, a template is defined and memory is allocated only after object instances. Objects of a given class can invoke the methods available to it without revealing the implementation details to the user which is often called abstraction and encapsulation.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# The first letter of the class name should always be a capital letter.
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="n"&gt;c1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;#c1 is the object of class car. 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

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

&lt;h2&gt;
  
  
  Distinguishing between class attributes and instance attributes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Class attributes are defined as part of the class definition and their values are meant to be the same across all instances created from that class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The class attributes can be accessed using the class name or instance name, although it is recommended to use as class name to access these attributes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The state or data of an object is provided by instance attributes.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="c1"&gt;#Instance of a class
&lt;/span&gt;    &lt;span class="n"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;#Instance attributes
&lt;/span&gt;    &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;blue&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;miles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We created an instance(car) of our Car class and then added two attributes to this instance: colour and miles. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The attributes added using this approach are instance attributes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Self
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Self is a reference to the instance that is being created. The use of self is to access the instance attributes and methods within the instance method, including the init method. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;self is not a keyword and can be anything such as this, that, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;It has to be the first parameter of the instance methods.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;

    &lt;span class="c1"&gt;#class attributes
&lt;/span&gt;    &lt;span class="n"&gt;c_mileage_units&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Mi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;miles&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;#Instance Variables
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;miles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;miles&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="c1"&gt;#Instance of a class
&lt;/span&gt;    &lt;span class="n"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;blue&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;#Instance attributes
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;miles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_mileage_units&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h2&gt;
  
  
  Constructors:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The constructor does nothing other than initialise the instance of a class.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The purpose of having constructors in a class is to initialise or assign the values to the class or instance level attributes mainly instance attributes whenever an instance of a class is being created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In Python, the &lt;strong&gt;init&lt;/strong&gt; method is known as the constructor and is always executed when new instances are created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There are three types of constructors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Default constructor &lt;/li&gt;
&lt;li&gt;Parameterized constructor &lt;/li&gt;
&lt;li&gt;Non-parameterized constructor&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;When we do not include any constructor in a class, then the class will use an empty default constructor.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;A parameterized constructor can take one or more arguments and the state of the instance can be set as per the input arguments provided through the constructor method.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;A non-parameterized constructor does not take any arguments except a reference to the instance being created.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Methods in a class
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;There are three types of methods in a class

&lt;ul&gt;
&lt;li&gt;Instance method &lt;/li&gt;
&lt;li&gt;Class method &lt;/li&gt;
&lt;li&gt;Static method&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Instance methods
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;They are associated with an instance and need an instance to be created first before executing them they accept the first attribute as a reference to the instance self and can read and update the state of the instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Class methods
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;These methods are declared with the &lt;a class="mentioned-user" href="https://dev.to/class"&gt;@class&lt;/a&gt; method decorator.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These methods don't need a class instance for execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For this method, the class reference(cls) will be automatically sent as the first argument.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Static methods
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;These methods are declared with the &lt;a class="mentioned-user" href="https://dev.to/static"&gt;@static&lt;/a&gt; method decorator.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They don't have access to cls or self-objects. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Static methods are like utility functions that take certain arguments and provide the output based on the argument values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Static method works like regular functions that we define in modules but are available in the context of the class's namespace.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;

        &lt;span class="c1"&gt;#class attributes
&lt;/span&gt;        &lt;span class="n"&gt;c_mileage_units&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Mi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;


        &lt;span class="c1"&gt;#Constructor
&lt;/span&gt;        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;miles&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="c1"&gt;#Instance Variables
&lt;/span&gt;            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;miles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;miles&lt;/span&gt;

        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print_color&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;color of the car is &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="nd"&gt;@classmethod&lt;/span&gt;
        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print_units&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mileage units are &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_mileage_units&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Class name is &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   

        &lt;span class="nd"&gt;@staticmethod&lt;/span&gt;
        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print_hello&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello from a static method&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

        &lt;span class="c1"&gt;#Instance of a class
&lt;/span&gt;        &lt;span class="n"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;blue&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


        &lt;span class="c1"&gt;#Instance attributes
&lt;/span&gt;        &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print_color&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print_units&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print_hello&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# We can trigger the instance method using the class name, but we need to pass the instance variable as the first argument.
&lt;/span&gt;    &lt;span class="c1"&gt;# This again explains why we need the self-argument for each instance method.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advantages of Object-Oriented Programming
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Mostly we discuss abstraction, encapsulation, polymorphism and inheritance in the advantages of object-oriented programming.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Abstraction Python is defined as hiding the implementation of logic from the client and using the particular application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Encapsulation in Python describes the content of bundling data and methods within a single unit example when you create a class it means you are implementing encapsulation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Class can inherit elements from another class. These elements include attributes and methods of the class from which we inherited under classes commonly known as parent classes. This is known as inheritance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Polymorphism is the ability of an instance to behave in multiple ways and a way to use the same method with the same name and the same arguments to behave differently following the class it belongs to. It can be implemented in two ways method overloading and method overriding&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;To know more about it click on the below links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.scaler.com/topics/oops-concepts-in-python/" rel="noopener noreferrer"&gt;Abstraction, Encapsulation, Inheritance, Polymorphism&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>api</category>
      <category>opensource</category>
      <category>contributorswanted</category>
      <category>discuss</category>
    </item>
    <item>
      <title>String Methods</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Thu, 16 Feb 2023 07:39:18 +0000</pubDate>
      <link>https://dev.to/roshansahurk/string-methods-2fac</link>
      <guid>https://dev.to/roshansahurk/string-methods-2fac</guid>
      <description>&lt;h2&gt;
  
  
  What are Strings?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Strings are the data structures which store a sequence of characters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Strings are immutable i.e. they cannot be changed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ex: "Hello"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;"Hello" is a string of characters with characters 'h', 'e', 'l', 'l', and 'o' in it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A string can be initialised by single quotes and double quotes. It throws an array if used in combinations of single quotes and double quotes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Initialise a string.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;abcde&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;   &lt;span class="c1"&gt;#Prints the output
&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;abcde&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The indexing on a string starts with 0 from the start and -1 from the end.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Accessing a particular index in a string.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Hello&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;e&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Concatenation in a string.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3.7&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python 3.7&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Slicing in a string is done with the help of square brackets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;s[start:stop:step]&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Pythonist&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;th&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h2&gt;
  
  
  Helper Functions in strings
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.capitalize()&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Returns a copy of a string with the first letter capitalised.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;capitalize&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Abcde&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

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

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.lower()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Return a copy of a string with all the characters in lowercase.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Hello WORLD&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;hello&lt;/span&gt; &lt;span class="n"&gt;world&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.upper()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Return a copy of a string with all the characters in lowercase.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;HELLO&lt;/span&gt; &lt;span class="n"&gt;WORLD&lt;/span&gt;   
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.split()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns a list with the space-separated elements.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;World&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.join()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns a string by joining the entire set of characters in a list or a tuple.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;H&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;e&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;l&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;l&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;o&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;W&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;o&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;l&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;d&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Hello World&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.swapcase()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns a copy of string but with lowercase letters to uppercase and vice versa.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Python&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;swapcase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pYTHON&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.casefold()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Return a copy of a string with all the characters in lowercase. It is the same as the string.lower()&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Hello WORLD&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;casefold&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;hello&lt;/span&gt; &lt;span class="n"&gt;world&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.center(width, fill_char)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns a copy of the string in the centre with added spaces to the right and left. It takes space as a fill character if nothing is given.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;HELLO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;center&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;------------HELLO-------------&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

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

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.count(string)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns an integer value stating the number of occurrences of a string in a string.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;HELLO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;L&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    
&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.endswith(string)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns True if the string end with the specified string.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Python&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;on&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.index(string)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns the index of the first occurrence in a string.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Hello World&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;o&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.isalnum()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns True if all characters in the string are alphanumeric.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;AabcD123&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isalnum&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;    
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.isalpha()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns True if all characters in the string are in the alphabet.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;abcd&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isalpha&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.isdecimal()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns True if all characters in the string are decimals.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1234&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isdecimal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.isdigit()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns True if all characters in the string are digits.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1234&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isdecimal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;    
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.islower()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns True if all characters in the string are lowercase.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;abcd&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;islower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;    
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;string.isupper()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns True if all characters in the string are uppercase.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ABCD&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isupper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;    
&lt;/code&gt;&lt;/pre&gt;

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

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

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To know more about the helper functions in a string, click on the below link.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.python.org/3/library/stdtypes.html#string-methods" rel="noopener noreferrer"&gt;String Methods&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>welcome</category>
    </item>
    <item>
      <title>Array Methods</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Thu, 16 Feb 2023 07:37:51 +0000</pubDate>
      <link>https://dev.to/roshansahurk/array-methods-2eh0</link>
      <guid>https://dev.to/roshansahurk/array-methods-2eh0</guid>
      <description>&lt;h1&gt;
  
  
  Array Methods
&lt;/h1&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Arrays are the data structures which store the same data type of elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The data type includes integer, float and character values.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Arrays can store more than one item at the same time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They are an ordered sequence of elements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Difference between array and list
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Arrays and lists are similar.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Arrays store only items that are of the same single data type but lists can store multiple data types.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Other properties are almost identical to each other.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sample codes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;array.array(datatype [array items])&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Initialise an array&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.typecode&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Return the type of the elements&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;typecode&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.itemssize&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns length in bytes of one array item&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;itemsize&lt;/span&gt;
&lt;span class="mi"&gt;4&lt;/span&gt;    
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.append(element)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Adds a value at the end of an array&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#TO KNOW THE OUTPUT 
&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.count(element)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Number of occurrences of argument in the array&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.extend(iter)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Append items from an iterable&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;74&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;56&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;74&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;56&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.insert(Index, element)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inserts an element in the index&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;74&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;56&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.pop()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Returns the last element and pops out the last element from an array.&lt;br&gt;
On passing an argument in the pop method it removes the element from the index. It takes the argument as an index.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="mi"&gt;56&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.reverse()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Reverse an array&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;    
&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;74&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;a.remove(element)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Removes the first occurrence of the element&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; a.remove&lt;span class="o"&gt;(&lt;/span&gt;5&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; a
array&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'i'&lt;/span&gt;, &lt;span class="o"&gt;[&lt;/span&gt;55, 74, 6, 5, 99, 4, 3, 2, 1]&lt;span class="o"&gt;)&lt;/span&gt;

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

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

&lt;h2&gt;
  
  
  Quick Overview of Array methods
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;a.typecode&lt;/td&gt;
&lt;td&gt;Returns the type of element in the list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a.itemsize&lt;/td&gt;
&lt;td&gt;Returns the byte capacity of the single item in the array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a.count()&lt;/td&gt;
&lt;td&gt;Counts the number of occurrences in the array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a.append()&lt;/td&gt;
&lt;td&gt;Appends the value to an array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a.extend&lt;/td&gt;
&lt;td&gt;Appends an array to an array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a.insert()&lt;/td&gt;
&lt;td&gt;Inserts an element at the given index&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a.pop()&lt;/td&gt;
&lt;td&gt;Pops out the last element from the array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a.reverse()&lt;/td&gt;
&lt;td&gt;Reverses the array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a.remove()&lt;/td&gt;
&lt;td&gt;Removes the element from the array&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To search for the data type, click on the below link.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.python.org/3/library/array.html" rel="noopener noreferrer"&gt;Data type&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>welcome</category>
    </item>
    <item>
      <title>Xargs, Printenv, Nano and Pipe</title>
      <dc:creator>Roshansahurk</dc:creator>
      <pubDate>Thu, 02 Feb 2023 06:28:00 +0000</pubDate>
      <link>https://dev.to/roshansahurk/xargs-printenv-nano-and-pipe-5f60</link>
      <guid>https://dev.to/roshansahurk/xargs-printenv-nano-and-pipe-5f60</guid>
      <description>&lt;h1&gt;
  
  
  Xargs
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Xargs stands for extended arguments. &lt;/li&gt;
&lt;li&gt;The function of Xargs is to build and execute command lines from standard input.&lt;/li&gt;
&lt;li&gt;xargs  is used in combination with  &lt;strong&gt;&lt;code&gt;rm&lt;/code&gt;&lt;/strong&gt;,  &lt;strong&gt;&lt;code&gt;cp&lt;/code&gt;&lt;/strong&gt;,  &lt;strong&gt;&lt;code&gt;mkdir&lt;/code&gt;&lt;/strong&gt;, and other similar commands.&lt;/li&gt;
&lt;li&gt;The synopsis for using Xargs command is:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xargs [options] [command [initial-arguments]] 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Xargs executes the command  one or more times with any  initial-arguments  followed  by items read from standard input. The default command used by xarg is /bin/echo. Below are the some basic examples for a better understanding of xargs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Combine Xargs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Let us consider the below two examples:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; find [location] -name "[search-term]" -type f | xargs [command] 
 find . -name '[search-term]' | xargs grep '[string-to-find-in-files]'
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;The first example above demonstrates using the  &lt;strong&gt;&lt;code&gt;find&lt;/code&gt;&lt;/strong&gt;  command to find all files. The list of files is then piped to  &lt;strong&gt;&lt;code&gt;xargs&lt;/code&gt;&lt;/strong&gt;, which uses the  reaspective  command.&lt;br&gt;
The last example above searched for all the files and piped them to &lt;strong&gt;&lt;code&gt;xargs&lt;/code&gt;&lt;/strong&gt;, which then executes the &lt;strong&gt;&lt;code&gt;grep&lt;/code&gt;&lt;/strong&gt; command on them.&lt;/p&gt;
&lt;h1&gt;
  
  
  Printenv
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Printenv stands for print environment.&lt;/li&gt;
&lt;li&gt; The function of the printenv is to print the values of the specified environment variables.
&lt;/li&gt;
&lt;li&gt;If no variable is specified, it prints out the name and value pairs.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The synopsis for using printenv command is:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;printenv [OPTION]... [VARIABLE]... 
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Let's display the values of specific environment variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ printenv HOME
 /root
$ printenv HOME SHELL
 /root 
 /bin/bash 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Nano
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Nano  is  a text editor loaded with several features such as opening multiple files, scrolling per line, undo/redo, syntax coloring, line numbering, and soft-wrapping overlong lines.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The synopsis for using nano command is:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano '[Complete-name-of-the-file-with-its-extesion]'
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;strong&gt;Use tab for autocompletion of file name&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Commands are entered by using the Control (^) and the Alt or Meta
   (M-)  keys. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic  Commands :
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Explanation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + V&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Scrolls page up.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + Y&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Scrolls page down.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + A&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Lets you jump to the beginning of the line.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + E&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Lets you to jump to the end of the line.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + G&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A Help window will pop out and show you all the available commands.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + O&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;To save the file. Nano will ask you to edit or verify the desired file name.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + K&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;It cuts the entire selected line to the cut buffer (similar to clipboard).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + U&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;To paste the text from the cut buffer into the selected line.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + C&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Shows the current cursor position in the text (line/column/character).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CTRL + X&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;To exit Nano text editor. It prompts a save request if you made any changes to the file.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ALT + A&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;To select text. You can combine this command with CTRL + K to cut a specific part of the text to the cut buffer.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Pipe
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Pipes are used for interprocess commmunication, i.e. it is used to combine two or more commands.&lt;/li&gt;
&lt;li&gt;The output generated by the output acts as an input for another command.&lt;/li&gt;
&lt;li&gt;Pipes are denoted by symbol &lt;strong&gt;&lt;code&gt;|&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Below are few examples where pipes are used.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat [name-of-the-file] | less
cat [name-of-the-file] | grep -v a | sort - r
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lets look at the output&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The  cat command is used to open the contents of file.&lt;/li&gt;
&lt;li&gt;The less command shows the contents of file into a readable format. &lt;/li&gt;
&lt;li&gt;The grep command is used to find strings and values in a document. &lt;/li&gt;
&lt;li&gt;Sort command sorts out the contents of a file.&lt;/li&gt;
&lt;li&gt;In the first example the contents of a file are piped into the less command, which in further opens the file into a more readable format.&lt;/li&gt;
&lt;li&gt;In the last example the contents of the file are piped into grep. The output produced by grep is piped into sort. The output generated by grep will be specified words. The sort command will sort the output generated by grep in reverse order.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On success, zero is returned.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On error, -1 is returned.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will see more about in above sections where pipes have been used with xargs. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cryptocurrency</category>
      <category>web3</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
