<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jyothula Sai jyothi on Medium]]></title>
        <description><![CDATA[Stories by Jyothula Sai jyothi on Medium]]></description>
        <link>https://medium.com/@jyothi.25bce8267?source=rss-f4bd5789c2ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xsj1LugdmF0xsGYE</url>
            <title>Stories by Jyothula Sai jyothi on Medium</title>
            <link>https://medium.com/@jyothi.25bce8267?source=rss-f4bd5789c2ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:34:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jyothi.25bce8267/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[OPERATORS IN PYTHON]]></title>
            <link>https://medium.com/@jyothi.25bce8267/operators-in-python-295df5cae42a?source=rss-f4bd5789c2ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/295df5cae42a</guid>
            <category><![CDATA[operators-in-python]]></category>
            <dc:creator><![CDATA[Jyothula Sai jyothi]]></dc:creator>
            <pubDate>Mon, 08 Dec 2025 13:46:20 GMT</pubDate>
            <atom:updated>2025-12-08T13:46:20.173Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Are Operators?</h3><p>Operators are special symbols or keywords in Python that perform operations on values or variables.<br> For example:</p><pre>3 + 5</pre><p>Here, + is an operator, and 3 and 5 are operands.</p><p>🌈 <strong>Category </strong>💠 <strong>Operators</strong></p><p>🧮 <strong>Arithmetic </strong>➜<strong> </strong>+ • - • * • / • % • // • **</p><p>🔍 <strong>Comparison </strong>➜<strong> </strong>== • != • &gt; • &lt; • &gt;= • &lt;=</p><p>🔐 <strong>Logica</strong>l➜ and • or • not</p><p>✏️ <strong>Assignment </strong>➜<strong> </strong>= • += • -= • *= • /= • %= • //= • **=</p><p>💡 <strong>Bitwise </strong>➜ &amp; • | • ^ • ~ • &lt;&lt; • &gt;&gt;</p><p>📦 <strong>Membership </strong>➜ in • not in</p><p>🪞 <strong>Identity </strong>➜ is •is not</p><h3>🧮<strong>Arithmetic Operators:</strong></h3><ul><li>Arithmetic operators are used to <strong>perform mathematical calculations </strong>.+ → addition, - → subtraction, * → multiplication ./ → division (always returns a float), // → floor division (integer result) .% → modulus (remainder), ** → exponentiation (power) .They work with <strong>integers and floats</strong> to produce numeric results.</li></ul><p>✨<strong> Addition</strong> ➜ +</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*LjspU-GiT9Vl77ojLHvp0A.jpeg" /></figure><p>✨<strong>Subtraction </strong>➜ —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*M7oPr1bErglSpHh6mHUZZw.jpeg" /></figure><p>✨ <strong>Multiplication </strong>➜ *</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*LwyX24ZFui_aa7RPataAvA.jpeg" /></figure><p>✨<strong>Division</strong>➜ /</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*DZBuqXPZ4lIzYeEv7hogyA.jpeg" /></figure><p>✨<strong>Modulus (Remainder)</strong> ➜ %</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*ArFsQo3qVtbDDZBzuttzgg.jpeg" /></figure><p>✨<strong>Floor Division</strong>➜ //</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*aBVZ1tkamsf93IqeOCvOyQ.jpeg" /></figure><p>✨<strong>Exponent (Power) </strong>➜**</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*ageTDTlhk91ZFFQV-Ew5HA.jpeg" /></figure><h3>🔍 <strong>Comparison:</strong></h3><ul><li>Comparison operators are used to <strong>compare two values </strong>.== → True if values are <strong>equal</strong>; != → True if values are <strong>not equal .</strong>&gt; → True if left value is <strong>greater</strong>; &lt; → True if left value is <strong>smaller </strong>.&gt;= → True if left value is <strong>greater or equal</strong>; &lt;= → True if left value is <strong>smaller or equal </strong>.They always return a <strong>Boolean value</strong> (True or False).</li></ul><p>✨<strong>Equal to </strong>— checks if two values are equal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*315-sRSXRNz9y7Q2H2ncrQ.jpeg" /></figure><p>✨<strong>Not equal to</strong> — checks if two values are not equal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*SOe5UqC7Ru_4aSpdgCoA_w.jpeg" /></figure><p>✨<strong>Greater than </strong>— checks if left value is greater than right value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*hmJEkkEwVQwquvkVIc5kcw.jpeg" /></figure><p>✨<strong>Less than</strong> — checks if left value is less than right value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*CXKQSBfOSO-tvBsaUhTyPw.jpeg" /></figure><p>✨<strong>Greater than or equal to</strong> — checks if left value is greater than or equal to right value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*sZOCrfFj2W6mb62zKcIhLg.jpeg" /></figure><p>✨<strong>Less than or equal to</strong> — checks if left value is less than or equal to right value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*72L9HAuOkzzaFmoFU1ArlA.jpeg" /></figure><h3><strong>🔐 Logical :</strong></h3><p>Logical operators are used to combine <strong>Boolean expressions .</strong>and → True if <strong>both conditions</strong> are True .or → True if <strong>at least one condition</strong> is True .not → <strong>Reverses</strong> the Boolean value (True → False, False → True).They are commonly used in <strong>if statements and conditional expressions</strong>.</p><p>✨<strong><em>and -</em></strong><em>True if both operands/conditions are True; otherwise False.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCe-TsR9kuwRrcI94jAwSw.jpeg" /></figure><p>✨<strong><em>or -</em></strong><em>True if at least one of the operands/conditions is True; False only if all are False.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovWgPmp-kuy2kI6MwnSpNg.jpeg" /></figure><p>✨<strong><em>not </em></strong><em>-Unary operator — reverses the truth value: True becomes False, False becomes True.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJQ5jcseIwq6dCjzv4vdyw.jpeg" /></figure><h3>✏️ <strong>Assignment:</strong></h3><p>Assignment operators are used to assign values to variables.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*uKB2qUe-EyrW7tOwsnME9A.jpeg" /></figure><p>✨+<strong>= </strong>➜ Assigns the value on the right-hand side to the variable on the left. t-side value to the variable, then assigns result to it (i.e. x += y is same as x = x + y).</p><p><strong>Syntax:</strong></p><pre>variable += value  # equivalent to variable = variable + value</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*bsUmcDJvfltrA3yfpc8hHA.jpeg" /></figure><p>✨<strong>-= </strong>➜ Subtract and assign: subtracts right-side value from variable, then assigns result to it (x -= y → x = x - y).</p><p><strong>Syntax:</strong></p><pre>variable -= value  # equivalent to variable = variable - value</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*wZN786x68hnwDhCXLPjaoA.jpeg" /></figure><p>✨<strong>*=</strong> ➜ Multiply and assign: multiplies variable by right-side value, then assigns result to it.</p><p><strong>Syntax:</strong></p><pre>variable *= value  # equivalent to variable = variable * value</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*tgsnQiuKbb6oz_Dq4oILCA.jpeg" /></figure><p>✨<strong>/=</strong> ➜ Divide and assign: divides variable by right-side value (float division), then assigns result.</p><p><strong>Syntax:</strong></p><pre>variable /= value  # equivalent to variable = variable / value</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*u6iE5-sPWMyXi_7pN8N5sg.jpeg" /></figure><p>✨<strong>//=</strong> ➜ Floor‑divide and assign: divides variable by right-side value using floor division, then assigns the integer‑part result.</p><p><strong>Syntax:</strong></p><pre>variable //= value  # equivalent to variable = variable // value</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*77L9CzOEomaggdKLg1dTEA.jpeg" /></figure><p>✨<strong>%=</strong> ➜ Modulus and assign: divides variable by right-side value, computes remainder, then assigns remainder.</p><p><strong>Syntax:</strong></p><pre>variable %= value  # equivalent to variable = variable % value</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*xNIo8tJ0NciTNA9DXuztkA.jpeg" /></figure><p>✨<strong>S</strong>**= ➜ Exponentiate and assign: raises variable to the power of right-side value, then assigns result.</p><p><strong>Syntax:</strong></p><pre>variable **= value  # equivalent to variable = variable ** value</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*0dLPmTNOLIHZzNOL0k360A.jpeg" /></figure><h3>💡 <strong>Bitwise:</strong></h3><p>Bitwise operators work <strong>on the binary representation</strong> of integers.&amp; (AND), | (OR), ^ (XOR), ~ (NOT) perform <strong>bit-level logical operations.</strong>&lt;&lt; (left shift) multiplies by powers of 2; &gt;&gt; (right shift) divides by powers of 2.They only work with <strong>integers</strong>, not floats or strings.Useful for <strong>flags, masks, and low-level data manipulation</strong></p><p>✨<strong>&amp; (Bitwise AND):</strong> Compares each bit of two numbers and returns 1 only if both bits are 1.<br> Used to <strong>mask</strong> or filter bits.</p><p><strong>Syntax:</strong></p><pre>a &amp; b</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*BnZySujqywLW5vZ2B0cmFA.jpeg" /></figure><p>✨<strong>| (Bitwise OR):</strong> Compares bits and returns 1 if <strong>any</strong> bit is 1.<br> Used to <strong>set</strong> specific bits.</p><p><strong>Syntax:</strong></p><pre>a | b</pre><p>Examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*Wt_mZqwHtYARKsuyYkMA6w.jpeg" /></figure><h4>✨^(Bitwise XOR )</h4><p>Sets a bit to 1 only when the two bits are different.<br> Commonly used to toggle bits or detect changes.^ (Bitwise XOR)</p><p>XOR = 1 when bits are <strong>different</strong>.</p><p><strong>Syntax:</strong></p><pre>a ^ b</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*8fwPxVdww5a7lhFegrgiUw.jpeg" /></figure><p>✨<strong>~ (Bitwise NOT):</strong> Inverts all bits, giving result -(x+1).<br> Produces the <strong>two’s complement</strong> negative.</p><p>Inverts bits → result becomes -(x+1).</p><p><strong>Syntax:</strong></p><pre>~a</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*CfoT6WdvzO5yzYotQCLH6g.jpeg" /></figure><p>✨<strong>&lt;&lt; (Left Shift):</strong> Shifts bits left and fills with zeros, effectively multiplying by 2ⁿ.<br> Used for <strong>fast multiplication</strong>.</p><p>Shifts bits to the left (adds zeros on the right).</p><p><strong>Syntax:</strong></p><pre>a &lt;&lt; n</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*rhyLbmnHnCnLuM1wHzPWsg.jpeg" /></figure><p>Explanation<br>The integer -5 is represented in binary using two’s complement notation.<br>In an 8-bit system, -5 is represented as 11111011<br>The &gt;&gt; operator shifts the bits of the number to the right by the specified number of<br>positions (in this case, 1 position).<br>For negative numbers, the sign bit (most significant bit) is preserved, which means the<br>leftmost bit remains 1.<br>Original binary of -5: 11111011<br>After shifting right by 1: 11111101<br>The binary 11111101 corresponds to -3 in decimal.</p><p>✨<strong>&gt;&gt; (Right Shift):</strong> Shifts bits right, dropping bits, effectively dividing by 2ⁿ.<br> Used for <strong>fast division</strong>.</p><h4>Syntax:</h4><pre>a &amp; b</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*0IvK9HqabMs3m46IfdWlUg.jpeg" /></figure><h3>📦 <strong>Membership:</strong></h3><p>In Python, <strong>membership</strong> refers to checking whether a <strong>value or element exists in a sequence or collection</strong> such as a list, tuple, string, set, or dictionary. Python provides two operators for this: in and not in.</p><h4>✨ in</h4><p>Checks whether a value exists inside a sequence (list, string, tuple, set, dict keys).<br> Returns <strong>True</strong> if the item is found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*RBMB-anyeBOBXsQOK9oFog.jpeg" /></figure><h4>✨ not in</h4><p>Checks whether a value does <em>not</em> exist inside a sequence.<br> Returns <strong>True</strong> if the item is <strong>not</strong> found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*h3G-kQHjqiieCB-7uOawJA.jpeg" /></figure><h3>🪞 <strong>Identity:</strong></h3><h3>What is Identity in Python?</h3><p>In Python, <strong>identity</strong> refers to <strong>whether two objects are actually the same object in memory</strong>. It’s <strong>different from equality</strong>, which checks if the values are the same. Identity is checked using the <strong>is</strong> and <strong>is not</strong> operators . Python also provides a built-in function <strong>id()</strong> to get the unique identity (memory address) of an object.</p><h4>✨ is</h4><p>Checks whether two variables point to the <strong>same object in memory</strong>.<br> Returns <strong>True</strong> if they refer to the same object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*hZVr6tlinuAAF4VoRIkrOw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*ZaW3T6DrM31JtSYhCUp5SQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*U8HTUjejn0kIo0AsspLGNQ.jpeg" /></figure><h4>✨ is not</h4><p>Checks whether two variables <strong>do not point to the same object</strong>.<br> Returns <strong>True</strong> if they refer to different objects</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*WQJNmyHHa_W9Ben1bQYahw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*LPLdnE0gfpvPXked1g-UOw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=295df5cae42a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>