<?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: CNavya21</title>
    <description>The latest articles on DEV Community by CNavya21 (@cnavya).</description>
    <link>https://dev.to/cnavya</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%2F1019297%2F8036f33d-1238-4f29-a0f4-d579a9d56861.png</url>
      <title>DEV Community: CNavya21</title>
      <link>https://dev.to/cnavya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cnavya"/>
    <language>en</language>
    <item>
      <title>Revision 11-03-2023</title>
      <dc:creator>CNavya21</dc:creator>
      <pubDate>Sat, 11 Mar 2023 09:46:05 +0000</pubDate>
      <link>https://dev.to/cnavya/revision-11-03-2023-1i9b</link>
      <guid>https://dev.to/cnavya/revision-11-03-2023-1i9b</guid>
      <description>&lt;h3&gt;
  
  
  1. What happens when you try to divide a number by 0 in JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If we divide with positive number by zero then it will return infinity.&lt;/li&gt;
&lt;li&gt;If we divide with zero by zero it will returns undefined.&lt;/li&gt;
&lt;li&gt;If we divide with negative number by zero then it will returns -infinity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. What is the difference between a traditional for loop and "for each" loop in JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt; The for loop that will use three optional expressions to implement the repeated execution of a code block.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (initialexpression; condition; updateexpression) {
    // for loop body
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;initialExpression &lt;strong&gt;:&lt;/strong&gt; it  declares variables and executes only once.&lt;/li&gt;
&lt;li&gt;condition &lt;strong&gt;:&lt;/strong&gt; it checks the condition, if the condition is false then loop will terminate and the condition is true then block of code inside of the for loop is executed.&lt;/li&gt;
&lt;li&gt;updateexpression &lt;strong&gt;:&lt;/strong&gt; updates the value of initialexpression when the condition is true.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const n = 3;
for (let i = 1; i &amp;lt;= n; i++) {
    console.log(`I love JavaScript.`);
}
# output: I love JavaScript.
          I love JavaScript.
          I love JavaScript.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The forEach() method calls a function (a callback function) for each element in an array.It doesn't execute for an empty array.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array.forEach(function(currentValue, index, arr), thisValue)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;currentValue &lt;strong&gt;:&lt;/strong&gt; It takes the current value of element.&lt;/li&gt;
&lt;li&gt;index &lt;strong&gt;:&lt;/strong&gt; It takes the index of current value of element.&lt;/li&gt;
&lt;li&gt;arr &lt;strong&gt;:&lt;/strong&gt; The array of current element.&lt;/li&gt;
&lt;li&gt;thisValue &lt;strong&gt;:&lt;/strong&gt; It takes defaultly undefined.A value passed to the function as its this value.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let students = ['John', 'Sara', 'Jack'];
students.forEach(myFunction);
function myFunction(item, index, arr) {
    arr[index] = 'Hello ' + item;
}
console.log(students);
# output: ["Hello John", "Hello Sara", "Hello Jack"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. What is the difference between Null and undefined in JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;null is a special value that represents an empty or unknown value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var test1 = null;
console.log(test1);
# output: null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Undefined means a variable has been declared, but the value of that variable has not yet been defined.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var test2;
console.log(test2);
# output : undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. How to activate the strict mode and what is its use in JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Strict mode is declared by adding "use strict"; to the beginning of a script or a function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strict mode eliminates JavaScript silent errors by changing them to throw errors.&lt;/li&gt;
&lt;li&gt;Fixes mistake that make it difficult for JavaScript engine to perform better.&lt;/li&gt;
&lt;li&gt;Make code run faster than identical code that's not in strict mode.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. What happens when you don't have a return statement in a function in JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The function will automatically returns undefined.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. What is the UNIQUE constraint in SQL and how is it different from PRIMARY KEY?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;UNIQUE constraint checks for all the values in a column or set of columns are different or not.&lt;/li&gt;
&lt;li&gt;Both the UNIQUE and PRIMARY KEY constraints provide a permission for uniqueness for a column or set of columns.&lt;/li&gt;
&lt;li&gt;A PRIMARY KEY constraint automatically has a UNIQUE constraint.&lt;/li&gt;
&lt;li&gt;You can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. What is the difference between PRIMARY KEY and FOREIGN KEY?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Primary key:

&lt;ul&gt;
&lt;li&gt;A primary key is used to ensure that data in the specific column is unique. A column cannot have NULL values. &lt;/li&gt;
&lt;li&gt;Only one primary key is allowed in a table.&lt;/li&gt;
&lt;li&gt;It does not allow NULL values.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.Foreign key:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables.&lt;/li&gt;
&lt;li&gt;Whereas more than one foreign key are allowed in a table.&lt;/li&gt;
&lt;li&gt;It contains NULL values.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. What is the unshift() method in JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It adds one or more elements in beginning of the array and returns the new array as output.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const array1 = [1, 2, 3];
console.log(array1.unshift(4, 5));
// Expected output: 5

console.log(array1);
// Expected output: Array [4, 5, 1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9. In JavaScript string methods, what is the difference between charAt() and charCodeAt(), and what will happen if no arguments are provided with these methods?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt; charAt() method returns the character at the specified index.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.charAt(index)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let text = "HELLO WORLD";
let letter = text.charAt(text.length-1);
#output: D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;charCodeAt() returns Unicode value of the character at the specified Index.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.charCodeAt(index)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let text = "HELLO WORLD";
let code = text.charCodeAt(0);
#output: 72
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If we don't pass any argument, then it will return the character and Unicode value of first character in the string respectively. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10. What is the difference between slice() and splice() in JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;slice() : This method is used to get a new array by selecting a sub-array of a given array.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.slice(start, end)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let text = "Hello world!"; 
let result = text.slice(3, 8);
#output: lo wo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;splice() : This method is used to add/remove an item from the given array.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;splice(start, deleteCount, item1, item2, itemN)
#start is the index from where you want to modify the array
#deleteCount is an optional parameter and refers to the number of elements to remove.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruits = ['mango', 'banana, 'apple', 'kiwi', 'orange']
fruits.splice(2)
#output: ['apple', 'kiwi', 'orange']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11. How do we ensure any package updates for any older dependencies get reflected in the package.json file?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;No, It won't reflect on the package.json file when we update the npm version.It remains the same version in the dependencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  12. How is atomicity achieved in a relational database?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The entire transaction takes place at once or doesn’t happen at all.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  13. What is the difference between the "for-each" loop and map method in JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The map() method returns a new array, whereas the forEach() method does not return a new array.&lt;/li&gt;
&lt;li&gt;The map() method is used to transform the elements of an array, whereas the forEach() method is used to loop through the elements of an array.&lt;/li&gt;
&lt;li&gt;The map() method can be used with other array methods, such as the filter() method, whereas the forEach() method cannot be used with other array methods.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>HTML &amp; CSS</title>
      <dc:creator>CNavya21</dc:creator>
      <pubDate>Thu, 02 Mar 2023 05:52:22 +0000</pubDate>
      <link>https://dev.to/cnavya/html-css-4pk5</link>
      <guid>https://dev.to/cnavya/html-css-4pk5</guid>
      <description>&lt;h2&gt;
  
  
  Box model
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When laying out a document, the browser's rendering engine represents each element as a rectangular box according to the standard CSS basic box model.&lt;/li&gt;
&lt;li&gt; CSS determines the size, position, and properties (color, background, border size, etc.) of these boxes.
*Every box is composed of four parts defined by their respective edges: the content edge, padding edge, border edge, and margin edge.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Content area&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The content area,  bounded by the content edge, contains the "real" content of the element, such as text, an image, or a video player. &lt;/li&gt;
&lt;li&gt;Its dimensions are the content width (or content-box width) and the content height (or content-box height). It often has a background color or background image.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Padding area&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The padding area, bounded by the padding edge, extends the content area to include the element's padding. Its dimensions are the padding-box width and the padding-box height.&lt;/li&gt;
&lt;li&gt;The thickness of the padding is determined by the padding-top, padding-right, padding-bottom, padding-left, and shorthand padding properties.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Border area&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The border area, bounded by the border edge, extends the padding area to include the element's borders. Its dimensions are the border-box width and the border-box height.&lt;/li&gt;
&lt;li&gt;The border area's size can be explicitly defined with the width, min-width, max-width, height, min-height, and max-height properties.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Margin area&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The margin area, bounded by the margin edge, extends the border area to include an empty area used to separate the element from its neighbors. Its dimensions are the margin-box width and the margin-box height.&lt;/li&gt;
&lt;li&gt;The size of the margin area is determined by the margin-top, margin-right, margin-bottom, margin-left, and shorthand margin properties.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Inline vs Block elements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In HTML elements historically were categorized as either "block-level" elements or "inline-level" elements. Since this is a presentational characteristic it is nowadays specified by CSS in the Flow Layout.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example for inline
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div&amp;gt;
  The following span is an &amp;lt;span class="highlight"&amp;gt;inline element&amp;lt;/span&amp;gt;; its
  background has been colored to display both the beginning and end of the
  inline element's influence.
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;/p&gt; block-level element contains some text. Within that text is a &lt;span&gt; element, which is an inline element. Because the &lt;span&gt; element is inline, the paragraph correctly renders as a single, unbroken text flow.
&lt;h3&gt;
  
  
  Example for block element
&lt;/h3&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div style="border: 1px solid black;"&amp;gt; About Us &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;h2&gt;
  
  
  Positioning: absolute/relative
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Absolute&lt;/li&gt;
&lt;li&gt;This is a very powerful type of positioning that allows you to literally place any page element exactly where you want it.&lt;/li&gt;
&lt;li&gt;You use the positioning attributes top, left, bottom, and right to set the location. &lt;/li&gt;
&lt;li&gt; Absolute positioned elements are removed from the normal flow, and can overlap elements.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;position: absolute;
&lt;/code&gt;&lt;/pre&gt;



&lt;ol&gt;
&lt;li&gt;Relative&lt;/li&gt;
&lt;li&gt;The relative positioning property is used to set the element relative to its normal position. &lt;/li&gt;
&lt;li&gt;Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;position: relative;
&lt;/code&gt;&lt;/pre&gt;



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

&lt;ul&gt;
&lt;li&gt;Structural pseudo classes allow access to the child elements present within the hierarchy of parent elements.&lt;/li&gt;
&lt;li&gt;We can select first-child element, last-child element, alternate elements present within the hierarchy of parent elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following is the list of structural classes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:first-child - it  represents the element that is prior to its siblings in a tree structure.&lt;/li&gt;
&lt;li&gt;:nth-child(n) - it applies CSS properties to those elements that appear at the position evaluated by the resultant of an expression.&lt;/li&gt;
&lt;li&gt;:last-child - it represents the element that is at the end of its siblings in a tree structure.&lt;/li&gt;
&lt;li&gt;:nth-last-child(n) - :nth-last-child(Expression) is the same as :nth-child(Expression) but the positioning of elements start from the end.&lt;/li&gt;
&lt;li&gt;:only-child - it represents the element that is a sole child of the parent element and there is no other sibling.&lt;/li&gt;
&lt;li&gt;:first-of-type - It selects the first element of the one type of sibling.&lt;/li&gt;
&lt;li&gt;:nth-of-type(n) - it represents those elements of the same type at the position evaluated by the Expression. &lt;/li&gt;
&lt;li&gt;:last-of-type - it represents the last element in the list of same type of siblings.&lt;/li&gt;
&lt;li&gt;:nth-last-of-type(n) - It is the same as :nth-of-type(n) but it starts counting of position from the end instead of start.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.container&lt;/strong&gt; : This class is used to create a container that holds the content of a web page or sometimes container which will hold other elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.header&lt;/strong&gt; : This class is used to style the header section of a web page, which typically contains the site logo, navigation menu, and other important information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.nav&lt;/strong&gt; : This class is used to style navigation menus on a web page, such as a top or side menu.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.btn&lt;/strong&gt; : This class is used to style buttons on a web page. It's often used to add a background color, border, and padding to create a clickable button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.card&lt;/strong&gt; : This class is used to create a card-style layout for content, such as a blog post or product listing. It often includes a background color, border, and padding to create a contained section for the content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.footer&lt;/strong&gt; : This class is used to style the footer section of a web page, which typically contains copyright information, social media links.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CSS specificity
&lt;/h2&gt;

&lt;p&gt;Specificity Hierarchy :Every element selector has a position in the Hierarchy. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Inline style: Inline style has highest priority. &lt;/li&gt;
&lt;li&gt;Identifiers(ID): ID have the second highest priority. &lt;/li&gt;
&lt;li&gt;Classes, pseudo-classes and attributes: Classes, pseudo-classes and attributes are come next. &lt;/li&gt;
&lt;li&gt;Elements and pseudo-elements: Elements and pseudo-elements have lowest priority. &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Start at 0, add 100 for each ID value, add 10 for each class value (or pseudo-class or attribute selector), add 1 for each element selector or pseudo-element.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A: h1
B: h1#content
C: &amp;lt;h1 id="content" style="color: pink;"&amp;gt;Heading&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The specificity of A is 1 (one element selector)&lt;br&gt;
The specificity of B is 101 (one ID reference + one element selector)&lt;br&gt;
The specificity of C is 1000 (inline styling)&lt;/p&gt;

&lt;h2&gt;
  
  
  Flex box / Grid
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Flex container&lt;/strong&gt;:The flex container specifies the properties of the parent. It is declared by setting the display property of an element to either flex or inline-flex.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flex items&lt;/strong&gt;:The flex items specify properties of the children. There may be one or more flex items inside a flex container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it is used to specify the direction of the flexible items inside a flex container. &lt;/li&gt;
&lt;li&gt;It is used to align the flex items horizontally when the items do not use all available space on the main-axis. &lt;/li&gt;
&lt;li&gt;It is used to align the flex items vertically when the items do not use all available space on the cross-axis.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The flex container properties are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;flex-direction&lt;/li&gt;
&lt;li&gt;flex-wrap&lt;/li&gt;
&lt;li&gt;flex-flow&lt;/li&gt;
&lt;li&gt;justify-content&lt;/li&gt;
&lt;li&gt;align-items&lt;/li&gt;
&lt;li&gt;align-content&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The flex item properties are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;order&lt;/li&gt;
&lt;li&gt;flex-grow&lt;/li&gt;
&lt;li&gt;flex-shrink&lt;/li&gt;
&lt;li&gt;flex-basis&lt;/li&gt;
&lt;li&gt;flex&lt;/li&gt;
&lt;li&gt;align-self&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;The @media rule, introduced in CSS2, made it possible to define different style rules for different media types.&lt;/li&gt;
&lt;li&gt;Media queries can be used to check many things, such as:

&lt;ul&gt;
&lt;li&gt;width and height of the viewport&lt;/li&gt;
&lt;li&gt;width and height of the device&lt;/li&gt;
&lt;li&gt;orientation (is the tablet/phone in landscape or portrait mode?)&lt;/li&gt;
&lt;li&gt;resolution&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media not|only mediatype and (expressions) {
  CSS-Code;
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Value and description:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all - Used for all media type devices&lt;/li&gt;
&lt;li&gt;print - Used for printers&lt;/li&gt;
&lt;li&gt;screen - used for computer screens, tablets, smart-phones etc.&lt;/li&gt;
&lt;li&gt;speech - Used for screenreaders that "reads" the page out loud&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (min-width: 480px) {
  body {
    background-color: lightgreen;
  }
}
&lt;/code&gt;&lt;/pre&gt;



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

&lt;ul&gt;
&lt;li&gt;The  tag is used to provide such additional information. This tag is an empty element and so does not have a closing tag but it carries information within its attributes.&lt;/li&gt;
&lt;li&gt;You can add metadata to your web pages by placing  tags inside the header of the document which is represented by  and  tags. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Attributes and descriptions
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Name

&lt;ul&gt;
&lt;li&gt;Name for the property. Can be anything. Examples include, keywords, description, author, revised, generator etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;content

&lt;ul&gt;
&lt;li&gt;Specifies the property's value.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;scheme

&lt;ul&gt;
&lt;li&gt;Specifies a scheme to interpret the property's value (as declared in the content attribute).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;http-equiv

&lt;ul&gt;
&lt;li&gt;Used for http response message headers. For example, http-equiv can be used to refresh the page or to set a cookie. Values include content-type, expires, refresh and set-cookie.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
      &amp;lt;title&amp;gt;Meta Tags Example&amp;lt;/title&amp;gt;
      &amp;lt;meta name = "keywords" content = "HTML, Meta Tags, Metadata" /&amp;gt;
   &amp;lt;/head&amp;gt;
   &amp;lt;body&amp;gt;
      &amp;lt;p&amp;gt;Hello HTML5!&amp;lt;/p&amp;gt;
   &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
# output: Hello HTML5!
&lt;/code&gt;&lt;/pre&gt;



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

</description>
    </item>
    <item>
      <title>SQL Concepts</title>
      <dc:creator>CNavya21</dc:creator>
      <pubDate>Tue, 21 Feb 2023 06:25:32 +0000</pubDate>
      <link>https://dev.to/cnavya/sql-concepts-16ok</link>
      <guid>https://dev.to/cnavya/sql-concepts-16ok</guid>
      <description>&lt;h2&gt;
  
  
  ACID
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The ACID properties define SQL database key properties to ensure consistent, safe and robust database modification when saved. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Atomicity&lt;/strong&gt; – Transaction acting on several pieces of information complete only if all pieces successfully save. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Consistency&lt;/strong&gt; - The saved data cannot violate the integrity of the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Isolation&lt;/strong&gt; - The separation of resource or data modifications made by different transactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Durability&lt;/strong&gt; - Ensures that changes made to the database (transactions) that are successfully committed will survive permanently, even in the case of system failures.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;It originally introduced as the CAP principle, can be used to explain some of the competing requirements in a distributed system with replication. &lt;/li&gt;
&lt;li&gt;The three letters in CAP refer to three desirable properties: 
&lt;strong&gt;consistency&lt;/strong&gt;(among replicated copies),
&lt;strong&gt;availability&lt;/strong&gt;(of the system for read and write operations) and &lt;strong&gt;partition tolerance&lt;/strong&gt; (in the face of the nodes in the system being partitioned by a network fault).&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;SQL Join statement is used to combine data or rows from two or more tables based on a common field between them. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Different types of Joins are as follows: &lt;br&gt;
&lt;strong&gt;1.INNER JOIN&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It selects all rows from both tables as long as the condition is satisfied.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;SELECT table1.column1,table1.column2,table2.column1,....&lt;br&gt;
FROM table1 &lt;br&gt;
INNER JOIN table2&lt;br&gt;
ON table1.matching_column = table2.matching_column;&lt;/p&gt;

&lt;p&gt;table1: First table.&lt;br&gt;
table2: Second table&lt;br&gt;
matching_column: Column common to both the tables.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT ord.OrderID, cust.CustomerName
FROM Orders ord
INNER JOIN Customers cust ON ord.CustomerID = cust.CustomerID; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;2.LEFT JOIN&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It returns all the rows of the table on the left side of the join and matches rows for the table on the right side of the join. &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;SELECT table1.column1,table1.column2,table2.column1,....&lt;br&gt;
FROM table1 &lt;br&gt;
LEFT JOIN table2&lt;br&gt;
ON table1.matching_column = table2.matching_column;&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT cust.CustomerName, ord.OrderID
FROM Customers cust
LEFT JOIN Orders ord ON cust.CustomerID = ord.CustomerID
ORDER BY cust.CustomerName;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;3.RIGHT JOIN&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It returns all the rows of the table on the right side of the join and matching rows for the table on the left side of the join.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;SELECT table1.column1,table1.column2,table2.column1,....&lt;br&gt;
FROM table1 &lt;br&gt;
RIGHT JOIN table2&lt;br&gt;
ON table1.matching_column = table2.matching_column;&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT cust.CustomerName, ord.OrderID
FROM Customers cust
RIGHT JOIN Orders ord ON cust.CustomerID = ord.CustomerID
ORDER BY cust.CustomerName;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;4.FULL JOIN&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It creates the result-set by combining results of both LEFT JOIN and RIGHT JOIN.&lt;/li&gt;
&lt;li&gt;The result-set will contain all the rows from both tables.&lt;/li&gt;
&lt;li&gt;For the rows for which there is no matching, the result-set will contain NULL values.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;SELECT table1.column1,table1.column2,table2.column1,....&lt;br&gt;
FROM table1 &lt;br&gt;
FULL JOIN table2&lt;br&gt;
ON table1.matching_column = table2.matching_column;&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT cust.CustomerName, ord.OrderID
FROM Customers cust
FULL JOIN Orders ord ON cust.CustomerID = ord.CustomerID
ORDER BY cust.CustomerName;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Aggregations, Filters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It performs a calculation on multiple values and returns a single value.&lt;/li&gt;
&lt;li&gt;SQL provides many aggregate functions that include avg, count, sum, min, max, etc.&lt;/li&gt;
&lt;li&gt;An aggregate function ignores NULL values when it performs the calculation, except for the count function.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Functions:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. count()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It returns the total number of rows from a database table that matches the criteria in the SQL query.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;count(*) or count(column_name)&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select count(*) from employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;2. sum()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It takes the name of the column as an argument and returns the sum of all the non NULL values in that column. &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;sum(column_name)&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select sum(emp_id) from employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;3. avg()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It uses the name of the column as an argument and returns the average of all the non NULL values in that column.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;avg(column_name)&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select avg(salary) from employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;4. max()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It takes the name of the column as an argument and returns the maximum value present in the column. MAX() returns NULL when no row is selected.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;max(column_name)&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select max(salary) from employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;5. min()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It takes the name of the column as an argument and returns the minimum value present in the column. MIN() returns NULL when no row is selected.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;min(column_name)&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select min(salary) from employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;6. filter()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The filter clause is used to, as the name suggests, filter the input data to an aggregation function.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;EXPRESSION&lt;br&gt;
AGGREGATION FUNCTION 1&lt;br&gt;
FILTER(WHERE CLAUSE)&lt;br&gt;
AGGREGATION FUNCTION 2&lt;br&gt;
FILTER(WHERE CLAUSE)&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
EXPRESSION&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select count(emp_id)
FILTER(WHERE ID!=2),
avg(length(Name))
FILTER(WHERE length(Name)&amp;gt;4)
from employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;7. group by&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;These statement groups rows that have the same values into summary rows.&lt;/li&gt;
&lt;li&gt;The GROUP BY statement is usually used along with aggregate functions such as count(), min(), max(), avg(), sum(), etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;select column_name(s)&lt;br&gt;
from table_name&lt;br&gt;
WHERE condition&lt;br&gt;
group by column_name(s)&lt;br&gt;
order by column_name(s);&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select COUNT(CustomerID), Country
from Customers
group by Country;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;8. having&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;These clause was added to SQL because the WHERE keyword cannot be used with aggregate functions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;expression&lt;br&gt;
group by CLAUSE&lt;br&gt;
having CLAUSE&lt;br&gt;
condition&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select emp_id
from employees
group by Name, employed
having employed = 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;ul&gt;
&lt;li&gt;These is the process to eliminate data redundancy and enhance data integrity in the table.
The database normalization process can be divided into following types:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1.First Normal Form (1NF)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data is stored in tables with rows that can be uniquely identified by a Primary Key.&lt;/li&gt;
&lt;li&gt;Data within each table is stored in individual columns in its most reduced form.There are no repeating groups.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Second Normal Form (2NF)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All the rules from 1NF must be satisfied.&lt;/li&gt;
&lt;li&gt;Only those data that relates to a table’s primary key is stored in each table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Third Normal Form (3NF)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All the rules from 2NF must be satisfied.&lt;/li&gt;
&lt;li&gt;There should be no intra-table dependencies between the columns in each table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Boyce-Codd Normal Form/Fourth Normal Form(BCNF of 4NF)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;BCNF stands for Boyce-Codd Normal Form, which is stronger than 3NF.&lt;/li&gt;
&lt;li&gt;This form which doesn’t contain any value dependency. A relation that is in 4NF also comes in BCNF. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Fifth Normal Form (5NF)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NF stands for Fifth Normal Form, where the relationship should be in 4NF to apply the fifth normal form. This normal form doesn’t contain any dependency.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Sixth Normal Form (6NF)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It stands for Sixth Normal Form, which is not a standardized form of normalization. Therefore it isn’t used nowadays and may give a clear and standardized normalization in the future. &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Indexes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An index helps to speed up SELECT queries and WHERE clauses, but it slows down data input, with the UPDATE and the INSERT statements. &lt;/li&gt;
&lt;li&gt;Indexes can be created or dropped with no effect on the data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To create index command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE INDEX index_name ON table_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To drop index command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DROP INDEX index_name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unique Index&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE UNIQUE INDEX index_name
on table_name (column_name);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To alter the index , we use rebuilding the existed table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ALTER INDEX IndexName 
ON TableName REBUILD;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;The following commands used to control transaction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;commit&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is used to save the changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;commit;&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; delete from Customers
  WHERE Age = 25;
&amp;gt; commit;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;rollback&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;These command used to undo transactions that have not already been saved to the database.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;rollback;&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; delete from Customers
  WHERE Age = 25;
&amp;gt; rollback;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;savepoint&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It creates points within the groups of transactions in which to ROLLBACK.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;SAVEPOINT SAVEPOINT_NAME;&lt;/p&gt;

&lt;p&gt;The syntax for rolling back to a SAVEPOINT is as shown below.&lt;br&gt;
ROLLBACK TO SAVEPOINT_NAME;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;set transaction&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Places a name on a transaction.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;SET TRANSACTION [ READ WRITE | READ ONLY ];&lt;/p&gt;

&lt;h2&gt;
  
  
  Locking mechanism
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;he lock is a mechanism associated with a table for restricting unauthorized access to the data.&lt;/li&gt;
&lt;li&gt;We can apply a lock on row level, database level, table level, and page level.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Modes of lock&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exclusive Lock (X)&lt;/li&gt;
&lt;li&gt;Shared Lock (S)&lt;/li&gt;
&lt;li&gt;Update Lock (U)&lt;/li&gt;
&lt;li&gt;Intent Lock (I)&lt;/li&gt;
&lt;li&gt;Schema Lock (Sch)&lt;/li&gt;
&lt;li&gt;Bulk Update Lock (BU)&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;It defines how one transaction is isolated from other transactions. 
Different types of isolation levels:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Read committed&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In select query it will take only committed values of table.&lt;/li&gt;
&lt;li&gt;If any transaction is opened and in-completed on table in others sessions then select query will wait till no transactions are pending on same table.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Read uncommitted&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is used when we want even the non-committed values of the rows.&lt;/li&gt;
&lt;li&gt;Any updates and inserts that are even not committed should be reflected in over transaction.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Repeatable read&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In select query data of the table that is used under transaction of isolation level "Repeatable Read" can not be modified from any other sessions till transaction is completed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Serializable&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is the strongest of all the Isolation Levels and guarantees pure isolation.&lt;/li&gt;
&lt;li&gt;No other transaction will be able to read and write values till this type of transaction is running on the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Snapshot&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it is similar to the serializable.&lt;/li&gt;
&lt;li&gt;The difference is Snapshot does not hold lock on table during the transaction so table can be modified in other sessions. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Data Definition Language(DDL) Trigger:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DDL triggers are fired in response to the DDL events, such as CREATE, ALTER, and DROP statements.&lt;/li&gt;
&lt;li&gt;We can create these triggers at the database level or server level, depending on the type of DDL events. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data Manipulation Language(DML) Trigger:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DML triggers are fired in response to DML events like INSERT, UPDATE, and DELETE statements in the user's table or view.&lt;/li&gt;
&lt;li&gt;It can also be executed in response to DML like operations performed by system-defined stored procedures.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Logon Triggers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It fire stored procedures in response to a LOGON event.&lt;/li&gt;
&lt;li&gt;This event is raised when the user session is established with an instance of SQL Server.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;ACID (&lt;a href="https://www.geeksforgeeks.org/acid-properties-in-dbms/"&gt;https://www.geeksforgeeks.org/acid-properties-in-dbms/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;CAP Theorem (&lt;a href="https://www.bmc.com/blogs/cap-theorem/"&gt;https://www.bmc.com/blogs/cap-theorem/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Joins (&lt;a href="https://www.geeksforgeeks.org/sql-join-set-1-inner-left-right-and-full-joins/"&gt;https://www.geeksforgeeks.org/sql-join-set-1-inner-left-right-and-full-joins/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Aggregation, filters (&lt;a href="https://www.scaler.com/topics/sql/aggregate-function-in-sql/"&gt;https://www.scaler.com/topics/sql/aggregate-function-in-sql/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Normalization (&lt;a href="https://www.sqlservercentral.com/articles/database-normalization-in-sql-with-examples"&gt;https://www.sqlservercentral.com/articles/database-normalization-in-sql-with-examples&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Indexes (&lt;a href="https://www.tutorialspoint.com/sql/sql-indexes.htm"&gt;https://www.tutorialspoint.com/sql/sql-indexes.htm&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Transactions (&lt;a href="https://www.tutorialspoint.com/sql/sql-transactions.html"&gt;https://www.tutorialspoint.com/sql/sql-transactions.html&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Locking mechanism (&lt;a href="https://www.javatpoint.com/locks-in-sql-server"&gt;https://www.javatpoint.com/locks-in-sql-server&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Database Isolation levels (&lt;a href="https://www.besttechtools.com/articles/article/sql-server-isolation-levels-by-example"&gt;https://www.besttechtools.com/articles/article/sql-server-isolation-levels-by-example&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>SOLID PRINCIPLES</title>
      <dc:creator>CNavya21</dc:creator>
      <pubDate>Mon, 20 Feb 2023 04:52:39 +0000</pubDate>
      <link>https://dev.to/cnavya/solid-principles-29c9</link>
      <guid>https://dev.to/cnavya/solid-principles-29c9</guid>
      <description>&lt;ul&gt;
&lt;li&gt;SOLID is a mnemonic abbreviation for a set of design principles created for software development in object-oriented languages.&lt;/li&gt;
&lt;li&gt;According to Orner, while the practice of software development has changed in the past 20 years, SOLID principles are still the basis of good design.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The SOLID Principles:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Single-Responsibility Principle (SRP)&lt;/li&gt;
&lt;li&gt;The Open-Closed Principle (OCP)&lt;/li&gt;
&lt;li&gt;The Liskov Substitution Principle (LSP)&lt;/li&gt;
&lt;li&gt;The Interface Segregation Principle (ISP)&lt;/li&gt;
&lt;li&gt;The Dependency inversion Principle (DIP)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Single-Responsibility Principle(SRP)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This states that a class should have a single responsibility, but more than that, a class should only have one reason to change. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;A change to one responsibility results to modification of the other responsibility.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Animal:
    def __init__(self, name: str):
        self.name = name
    def get_name(self) -&amp;gt; str:
        pass
    def save(self, animal: Animal):
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make this conform to SRP, we create another class that will handle the sole responsibility of storing an animal to a database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Animal:
    def __init__(self, name: str):
            self.name = name
    def get_name(self):
        pass
class AnimalDB:
    def get_animal(self) -&amp;gt; Animal:
        pass
    def save(self, animal: Animal):
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;In the open/closed principle classes should be open for extension, but closed for modification. &lt;/li&gt;
&lt;li&gt;Essentially meaning that classes should be extended to change functionality, rather than being altered into something else.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Let’s imagine you have a store, and you give a discount of 20% to your favorite customers using this class:&lt;br&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Discount:
    def __init__(self, customer, price):
        self.customer = customer
        self.price = price

    def give_discount(self):
            if self.customer == 'fav':
                return self.price * 0.2
            if self.customer == 'vip':
                return self.price * 0.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make it follow the OCP principle, we will add a new class that will extend the Discount. &lt;br&gt;
In this new class, we would implement its new behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Discount:
    def __init__(self, customer, price):
        self.customer = customer
        self.price = price
    def get_discount(self):
            return self.price * 0.2
class VIPDiscount(Discount):
    def get_discount(self):
        return super().get_discount() * 2
class SuperVIPDiscount(VIPDiscount):
    def get_discount(self):
        return super().get_discount() * 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Liskov Substitution Principle (LSP)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A sub-class must be substitutable for its super-class.&lt;/li&gt;
&lt;li&gt;The aim of this principle is to ascertain that a sub-class can assume the place of its super-class without errors. &lt;/li&gt;
&lt;li&gt;If the code finds itself checking the type of class then, it must have violated this principle.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Let’s use our Animal example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def animal_leg_count(animals: list):
    for animal in animals:
        if isinstance(animal, Lion):
            print(lion_leg_count(animal))
        elif isinstance(animal, Mouse):
            print(mouse_leg_count(animal))
        elif isinstance(animal, Pigeon):
            print(pigeon_leg_count(animal))

animal_leg_count(animals)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make this function follow the LSP principle, we will follow this LSP requirements postulated by Steve Fenton:&lt;br&gt;
If the super-class (Animal) has a method that accepts a super-class type (Animal) parameter. &lt;br&gt;
Its sub-class(Pigeon) should accept as argument a super-class type (Animal type) or sub-class type(Pigeon type).&lt;br&gt;
If the super-class returns a super-class type (Animal). &lt;br&gt;
Its sub-class should return a super-class type (Animal type) or sub-class type(Pigeon).&lt;br&gt;
Now, we can re-implement animal_leg_count function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def animal_leg_count(animals: list):
    for animal in animals:
        print(animal.leg_count())

animal_leg_count(animals)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The animal_leg_count function cares less the type of Animal passed, it just calls the leg_count method. &lt;br&gt;
All it knows is that the parameter must be of an Animal type, either the Animal class or its sub-class.&lt;br&gt;
The Animal class now have to implement/define a leg_count method.&lt;br&gt;
And its sub-classes have to implement the leg_count method:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Make fine grained interfaces that are client specific&lt;/li&gt;
&lt;li&gt;Clients should not be forced to depend upon interfaces that they do not use.&lt;/li&gt;
&lt;li&gt;This principle deals with the disadvantages of implementing big interfaces.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Let’s look at the below IShape interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class IShape:
    def draw_square(self):
        raise NotImplementedError
    def draw_rectangle(self):
        raise NotImplementedError
    def draw_circle(self):
        raise NotImplementedError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, our IShape interface performs actions that should be handled independently by other interfaces.&lt;br&gt;
To make our IShape interface conform to the ISP principle, we segregate the actions to different interfaces.&lt;br&gt;
Classes (Circle, Rectangle, Square, Triangle, etc) can just inherit from the IShape interface and implement their own draw behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class IShape:
    def draw(self):
        raise NotImplementedError
class Circle(IShape):
    def draw(self):
        pass
class Square(IShape):
    def draw(self):
        pass
class Rectangle(IShape):
    def draw(self):
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Dependency should be on abstractions not concretions

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


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

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class XMLHttpService(XMLHttpRequestService):
    pass

class Http:
    def __init__(self, xml_http_service: XMLHttpService):
        self.xml_http_service = xml_http_service
    def get(self, url: str, options: dict):
        self.xml_http_service.request(url, 'GET')
    def post(self, url, options: dict):
        self.xml_http_service.request(url, 'POST')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Connection interface has a request method. With this, we pass in an argument of type Connection to our Http class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Http:
    def __init__(self, http_connection: Connection):
        self.http_connection = http_connection
    def get(self, url: str, options: dict):
        self.http_connection.request(url, 'GET')
    def post(self, url, options: dict):
        self.http_connection.request(url, 'POST')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can now re-implement our XMLHttpService class to implement the Connection interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class XMLHttpService(Connection):
    xhr = XMLHttpRequest()

    def request(self, url: str, options:dict):
        self.xhr.open()
        self.xhr.send()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class NodeHttpService(Connection):
    def request(self, url: str, options:dict):
        pass

class MockHttpService(Connection):
    def request(self, url: str, options:dict):
        pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.hashbangcode.com/article/solid-principles-python"&gt;https://www.hashbangcode.com/article/solid-principles-python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>OOP CONCEPT IN PYTHON</title>
      <dc:creator>CNavya21</dc:creator>
      <pubDate>Thu, 16 Feb 2023 06:40:47 +0000</pubDate>
      <link>https://dev.to/cnavya/python-oops-concept-18j1</link>
      <guid>https://dev.to/cnavya/python-oops-concept-18j1</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Python is an object-oriented language.&lt;/li&gt;
&lt;li&gt;An object-oriented is to design the program using classes and objects.&lt;/li&gt;
&lt;li&gt;The main concept of OOP's is to bind the data and the functions that work on that together as a single unit so that no other part of the code can access this data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Main concepts of OOP's
&lt;/h2&gt;

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

&lt;ul&gt;
&lt;li&gt;Class is defined as a collection of objects.&lt;/li&gt;
&lt;li&gt;It contains the blueprints of objects.&lt;/li&gt;
&lt;li&gt;Classes are created by keyword class.&lt;/li&gt;
&lt;li&gt;Attributes are the variables that belong to a class.&lt;/li&gt;
&lt;li&gt;Attributes are always public and can be accessed using dot(.) operator. Eg: Myclass.Application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ClassName:
    # statement-1
    .
    .
    .
    # statement-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Dog:
    pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Object
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The object is an entity that has state and behavior.&lt;/li&gt;
&lt;li&gt;A method is a function that belongs to an object.&lt;/li&gt;
&lt;li&gt;It may be any real-world object like a mouse, keyboard, chair, table, pen, etc.&lt;/li&gt;
&lt;li&gt;Everything in Python is an object, and almost everything has attributes and methods.&lt;/li&gt;
&lt;li&gt;State : It is represented by the attributes of an object and also reflects the properties of an object. &lt;/li&gt;
&lt;li&gt;Behavior : It is represented by the methods of an object and also reflects the response of an object to other objects.&lt;/li&gt;
&lt;li&gt;Identity : It gives a unique name to an object and enables one object to interact with other objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  self
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It represents the instance of the class.&lt;/li&gt;
&lt;li&gt;It allows you to access variables, attributes and methods of a defined class.&lt;/li&gt;
&lt;li&gt;The self parameter doesn't have to be named “self,” as you can call it by any other name.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Dog:
    def __init__(self, breed, colour):
        self.breed = breed
        self.colour = colour
    def display(self):
        print(self.breed, self.colour)
d = Dog("Samoyed", "White")
d.display()
# output: Samoyed White
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Inheritance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Inheritance is the capability of one class to derive or inherit the properties from another class. &lt;/li&gt;
&lt;li&gt;It represents real-world relationships well.&lt;/li&gt;
&lt;li&gt;It provides the reusability of a code and it allows us to add more features to a class without modifying it.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;h4&gt;
  
  
  1.Single Inheritance
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It enables a derived class to inherit characteristics from a single-parent class.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2.Multilevel Inheritance
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It enables a derived class to inherit properties from an immediate parent class which in turn inherits properties from his parent class.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3.Hierarchical Inheritance
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It enables more than one derived class to inherit properties from a parent class.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4.Multiple Inheritance
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It enables one derived class to inherit properties from more than one base class.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class BaseClass:
    {body}
class DerivedClass(BaseClass):
    {body}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person(object):
    def __init__(self, name):
        self.name = name
    def getName(self):
        return self.name
    def isEmp(Person):
        return False
class Employee(Person):
    def isEmployee(self):
        return True
per = Person("Abhi")
print(per.getName(), per.isEmployee())

per = Person("Visal")
print(per.getName(), per.isEmployee())
# output: Abhi False
          Visal False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Polymorphism
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Polymorphism contains two words "poly" and "morphs". &lt;/li&gt;
&lt;li&gt;It means having many forms.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add(x, y, z = 0):
    return x + y + z

print(add(2, 3))
print(add(2, 3, 4))
# output : 5
           9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Method Overriding
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super-classes or parent classes. &lt;/li&gt;
&lt;li&gt;When a method in a subclass has the same name, same parameters or signature and same return type as a method in its super-class, then the method in the subclass is said to override the method in the super-class.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Parent():
    def __init__(self):
        self.value = "Inside Parent"
    def show(self):
        print(self.value)
class Child(Parent):
    def __init__(self):
        self.value = "Inside Child"
    def show(self):
        print(self.value)


obj1 = Parent()
obj2 = Child()

obj1.show()
obj2.show()
#output: Inside Parent
     Inside Child
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Method Overloading
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Two or more methods have the same name but different numbers of parameters or different types of parameters, or both.&lt;/li&gt;
&lt;li&gt;The problem with method overloading in Python is that we may overload the methods but can only use the latest defined method. &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def product(a, b):
    p = a * b
    print(p)

def product(a, b, c):
    p = a * b * c
    print(p)

product(4, 5, 5)
#output: 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Encapsulation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It describes the idea of wrapping data and the methods that work on data within one unit.&lt;/li&gt;
&lt;li&gt;This puts restrictions on accessing variables and methods directly and can prevent the accidental modification of data.&lt;/li&gt;
&lt;li&gt;Protected members(single underscore"_") are those members of the class that cannot be accessed outside the class but can be accessed from within the class and its subclasses.&lt;/li&gt;
&lt;li&gt;Private members(double underscore"__") are similar to protected members, the difference is that the class members declared private should neither be accessed outside the class nor by any base class.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Base:
    def __init__(self):
        self._a= 2
class Derived(Base):
    def __init__(self):
        Base.__init__(self)
        print("Base class: ", self._a)

        self._a = 3
        print("Outside class: ", self._a)
obj1 = Derived()
obj2 = Base()

print("Accessing obj1: ", obj1._a)
print("Accessing obj2: ", obj2._a)
#output: Base class:  2
    Outside class:  3
    Accessing obj1:  3
    Accessing obj2:  2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Data Abstraction
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It hides the unnecessary code details from the user.&lt;/li&gt;
&lt;li&gt;It can be achieved through creating abstract classes.&lt;/li&gt;
&lt;li&gt;data hiding: We use double underscore("__") before the attributes names and those attributes will not be directly visible outside.&lt;/li&gt;
&lt;li&gt;Printing objects :Printing objects give us information about objects we are working with.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyClass:
     __hiddenVariable = 0
     def add(self, increment):
        self.__hiddenVariable += increment
        print (self.__hiddenVariable)

myObject = MyClass()     
myObject.add(2)
myObject.add(5)

print (myObject.__hiddenVariable)
#output: 2
         7
Traceback (most recent call last):
  File "filename.py", line 13, in 
    print (myObject.__hiddenVariable)
AttributeError: MyClass instance has 
no attribute '__hiddenVariable' 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In Python, Object-Oriented programming(OOP's) is a programming paradigm that uses objects and classes in programming. It aims to implement real-world entities like inheritance, polymorphism, encapsulation, etc. in the programming.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Reference links for OOP's concepts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1.(&lt;a href="https://www.geeksforgeeks.org/python-oops-concepts/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/python-oops-concepts/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;2.(&lt;a href="https://www.javatpoint.com/python-oops-concepts" rel="noopener noreferrer"&gt;https://www.javatpoint.com/python-oops-concepts&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>productivity</category>
    </item>
    <item>
      <title>PYTHON : STRING METHODS</title>
      <dc:creator>CNavya21</dc:creator>
      <pubDate>Thu, 16 Feb 2023 04:10:14 +0000</pubDate>
      <link>https://dev.to/cnavya/python-array-methods-3d4a</link>
      <guid>https://dev.to/cnavya/python-array-methods-3d4a</guid>
      <description>&lt;h3&gt;
  
  
  capitalize()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It returns the string in the form of first character is upper case and the rest in lower case.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.capitalize()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "hi, welcome!"
a = txt.capitalize()
print(a)
#output:Hi, welcome!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  casefold()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It returns the string where all the characters are lower case.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.casefold()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "This Is My Example"
x = txt.casefold()
print(x)
#output: this is my example
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  center()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It is a string class function that is used to position a string by padding it with a specified character.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.center(length, character)
#length - length of the required string.
#character - to fill the missing space on each side and default is " "(space).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "banana"
x = txt.center(20, "x")
print(x)
#output: xxxxxxxbananaxxxxxxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  count()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This method returns the number of times a specified value appears in the string.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.count(value, start, end)
#value - value to search for a string
#start - position to start the search and default is 0
#end - position to end the search and default is end of the string
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "I love apples, apple are my favorite fruit"
x = txt.count("apple", 10, 24)
print(x)
#output: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  endswith()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This method method returns True if the string ends with the specified value, otherwise False.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.endswith(value, start, end)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "Hello, welcome to my world."
x = txt.endswith("!")
print(x)
#output:False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  expandtabs()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This method sets the tab size to the specified number of whitespaces.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.expandtabs(tabsize)
#tabsize - a number specifying the tabsize and default is 8.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "W\te\tl\tc\to\tm\te"
print(txt.expandtabs(1)) 
#output: W e l c o m e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  find()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It finds the first occurrence of the specified value.&lt;/li&gt;
&lt;li&gt;It will returns -1 if the value not found.&lt;/li&gt;
&lt;li&gt;This method is almost same as index() method, the only difference is that the index() method rasie an exception if the value is not found.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.find(value, start, end)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "Hello, welcome to my world."
x = txt.find("n")
print(x)
#output: -1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  format()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This method formats the specified value or values and insert them inside the string placeholder.&lt;/li&gt;
&lt;li&gt;the placeholder is defined using curly brackets {}.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.format(value1, value2,....)
# values can required one or more values . 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "For only {price:.2f} dollars!"
print(txt.format(price = 49))
#output: For only 49.00 dollars! 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  index()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This method finds the first occurrence of the specified value.&lt;/li&gt;
&lt;li&gt;It raises an exception if the value is not found.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.index(value, start, end)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "Hello, welcome to my world."
x = txt.index("m")
print(x)
#ouput: 12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  isalnum()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This method returns true if all the characters are alphanumeric ,means letter(a-z) and numbers (0-9).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.isalnum()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "company123"
x = txt.isalnum()
print(x)
#output: True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  isalpha()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It returns true if all the characters are alphabet letters(a-z).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.isalpha()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "company123"
x = txt.isalpha()
print(x)
#output: False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  isascii()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It returns True if all the characters are ascii characters(a-z).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.isascii()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "company123"
x = txt.isascii()
print(x)
#output: true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  isdecimal()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It returns True if all the characters are decimanls(0-9).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.isdecimal()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = "\u0030"
print(a.isdecimal())
#ouput: True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  swapcase()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It returns a string where all the upper case letters to lower case and vise versa.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.swapcase()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "Hello My Name Is PETER"
x = txt.swapcase()
print(x) 
#output:hELLO mY nAME iS peter 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  join()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It takes all items in an iterable and joins them into one string.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.join(iterable)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myDict = {"name": "John", "country": "Norway"}
mySeparator = "TEST"
x = mySeparator.join(myDict)
print(x)
#ouput: nameTESTcountry 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  split()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It splits into a list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.split(separator, maxsplit)
#separator - use when splitting the string and by default any whitespace is a separator
# maxsplit - how many splits to do and default value is -1, which is "all occurrences"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "apple#banana#cherry#orange"
x = txt.split("#")
print(x)
#output: ['apple', 'banana', 'cherry', 'orange']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  zfill()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It adds zeros at the beginning of the string, until it reaches the specified length.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.zfill(len)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "50"
x = txt.zfill(10)
print(x)
#output: 0000000050
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  upper()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It returns a string where all characters are in upper case.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string.upper()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = "hello"
a = txt.upper()
print(a)
# output: HELLO
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>string</category>
      <category>methods</category>
    </item>
    <item>
      <title>PYTHON : ARRAY METHODS</title>
      <dc:creator>CNavya21</dc:creator>
      <pubDate>Wed, 15 Feb 2023 11:29:37 +0000</pubDate>
      <link>https://dev.to/cnavya/python-array-methods-hhj</link>
      <guid>https://dev.to/cnavya/python-array-methods-hhj</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Arrays is a collections of one or more items at the same time.&lt;/li&gt;
&lt;li&gt;We can access the elements using index values of array.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  append()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It is used to add or append the element to existing array at the end of array list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.append(element)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = [1, 2, 3]
b = [7, 8, 9]
b.append(2)
print(b)
# output: [7, 8, 9, [1, 2, 3]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  clear()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It is used to clear or remove all the elements in the array list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.clear()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = ["Hi", "Welcome", "Bye"]
a.clear()
print(a)
# output: []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;It is used to copy the specific list of data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax of copy
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.copy()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = ["ball", "bat", "cat", "dog"]
x = a.copy()
print(x)
# output: ['ball', 'bat', 'cat', 'dog']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  count()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It gives the number of elements for specified value in the list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.count(value)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n = [1,2,3,4,1,3,6,4,8]
m = n.count(3)
print(m)
# output: 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  extend()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It adds the specific list of elements at the end of the current array list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.extend(iterable)
# iterable - it can be a list, set, tuple etc.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n = ['This is a list']
m = ['List of elements.']
m.extend(n)
print(m)
# output: ['This is a list', 'List of elements.']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  index()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It returns the index value of a specific element.&lt;/li&gt;
&lt;li&gt;if we have duplicates in the list, the index will the take the first occurs of the element in the list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.index(elemnt)
#elemnt - it can be string, number, list etc.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n = [1,2,3,4,1,3,6,4,8]
x = n.index(4)
print(x)
# output: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  insert()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt; It used to insert the element at specific index value in the array.
#### Syntax
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.insert(pos, elemnt)
# pos - at which position of index we want to insert.
# elemnt - it can be string, number, object etc.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = ['ball', 'bat', 'cat', 'dog']
a.insert(1, 'lion']
print(a)
# output: ['ball', 'lion', 'bat', 'cat', 'dog']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  pop()
&lt;/h3&gt;

&lt;p&gt;*It removes the element at a specific value.&lt;/p&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.pop(pos)
#pos - at which position of index we want.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = ['ball', 'bat', 'cat', 'dog']
a.pop(1)
print(a)
# output: ['ball', 'cat', 'dog']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  remove()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It removes the first occurrence of  the element with specified value.
#### Syntax
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.remove(elemnt)
#elemnt - it can be string, number, list etc.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n = [1,2,3,4,1,3,6,4,8]
n.remove(1)
print(n)
# output: [2, 3, 4, 1, 3, 6, 4, 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  reverse()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It create a new string containing the original data in reverse order.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.reverse()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = ['ball', 'bat', 'cat', 'dog']
a.reverse()
print(a)
# output: ['dog', 'cat', 'bat', 'ball']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  sort()
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It will sort the list in ascending order by default.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list.sort(reverse = true|false, key=myfun)
#reverse -  reverse=True will sort the list descending. Default is reverse=False
#key - function to specify the sorting criteria.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n = [1,2,3,4,1,3,6,4,8]
n.sort()
print(n)
# output: [1, 1, 2, 3, 3, 4, 4, 6, 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>array</category>
      <category>methods</category>
    </item>
    <item>
      <title>Basic Cli commands(sudo, apt, touch, cat, less)</title>
      <dc:creator>CNavya21</dc:creator>
      <pubDate>Thu, 02 Feb 2023 04:41:19 +0000</pubDate>
      <link>https://dev.to/cnavya/basic-cli-commandssudo-apt-touch-cat-less-2829</link>
      <guid>https://dev.to/cnavya/basic-cli-commandssudo-apt-touch-cat-less-2829</guid>
      <description>&lt;h3&gt;
  
  
  Sudo
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It allow a user with proper permissions to execute a command as another user, such as the superuser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Flags of sudo
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;-V : used to check the version. &lt;/li&gt;
&lt;li&gt;-l : used to list which we have to print from current host.&lt;/li&gt;
&lt;li&gt;-v : sudo will update the user’s timestamp, prompting for the user’s password if necessary.&lt;/li&gt;
&lt;li&gt;-h : used to help.&lt;/li&gt;
&lt;li&gt;-k : it used to sudo invalidates the user’s timestamp.&lt;/li&gt;
&lt;li&gt;-K : it used to remove the user’s timestamp entirely.&lt;/li&gt;
&lt;li&gt;-b : it tells sudo to run the given command in the background.&lt;/li&gt;
&lt;li&gt;-p : allows you to override the default password prompt and use a custom one.&lt;/li&gt;
&lt;li&gt;-u : user can run the specified command as a user other than root.&lt;/li&gt;
&lt;li&gt;-s : runs the shell specified by the SHELL environment variable if it is set or the shell as specified in the file password. &lt;/li&gt;
&lt;li&gt;- : indicates that sudo should stop processing command line arguments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax of sudo
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo [command]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  apt (Advanced Packaging Tool)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It perform as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install package&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install &amp;lt;package_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Update package in index
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove a package
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt remove &amp;lt;package_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Upgrade package
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  touch
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It is used to create a file, update the modification and access time of each file with the help of touch command.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax of touch
&lt;/h4&gt;



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

&lt;/div&gt;



&lt;h4&gt;
  
  
  Flags in touch
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;-a : used to change the access time of a file.&lt;/li&gt;
&lt;li&gt;-m : help you to change only the modification time of a file.&lt;/li&gt;
&lt;li&gt;-r : it update time with reference to the other mentioned command.&lt;/li&gt;
&lt;li&gt;-t : we can change the access time of a file by determining a specified time to it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  cat
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create a file bye using '&amp;gt;' symbol.&lt;/li&gt;
&lt;li&gt;It can read the data inside the file.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Syntax of cat
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;create a file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;gt; 'file_name'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;to read a file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat 'file_name'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  less
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It automatically adjust with the width and height of the terminal window.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;less 'file_name'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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