

{"id":5911,"date":"2018-01-13T05:40:01","date_gmt":"2018-01-13T00:10:01","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=5911"},"modified":"2026-04-28T11:02:03","modified_gmt":"2026-04-28T05:32:03","slug":"python-bitwise-operators","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/","title":{"rendered":"Python Bitwise Operators with Syntax and Example"},"content":{"rendered":"<p>In this Python Bitwise Operators Tutorial, we will discuss Python Bitwise AND, OR, XOR, Left-shift, Right-shift, and 1&#8217;s complement Bitwise Operators in Python Programming.<\/p>\n<p>Along with this, we will discuss syntax and examples of Python Bitwise Operators.<\/p>\n<p>So, let&#8217;s start the Python Bitwise Operators Tutorial.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5912 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python.jpg\" alt=\"Python Bitwise Operators with Syntax and Example\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a> Python Bitwise Operators with Syntax and Example<\/p>\n<h3>What are Python Bitwise Operators?<\/h3>\n<p>Python Bitwise Operators take one to two operands, and operate on it\/them bit by bit, instead of whole.<\/p>\n<p><strong>Characteristics of bitwise operators in Python:<\/strong><\/p>\n<ul>\n<li><strong>Binary process:<\/strong> These operators work on numbers by converting them into binary language(0s and 1s).<\/li>\n<li><strong>Use of integers:<\/strong> Bitwise operators are mainly used with integer values.<\/li>\n<li><strong>Integer result:<\/strong> After every operation, the result is always shown as an integer.<\/li>\n<li><strong>Low-level tasks:<\/strong> It is commonly used in cryptography, performance optimisation, and system programming.<\/li>\n<\/ul>\n<p>To take an example, let\u2019s see the \u2018and\u2019 and \u2018&amp;\u2019 operators for the same thing.<\/p>\n<p>Let\u2019s take two numbers- 5 and 7. We\u2019ll show you their binary equivalents using the function bin().<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; bin(5)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;0b101&#8217;<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; bin(7)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;0b111&#8217;<\/div>\n<p>Now let\u2019s try applying \u2018and\u2019 and \u2018&amp;\u2019 to 5 and 7.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 5 and 7<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">7<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 5&amp;7<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">5<\/div>\n<p>You would have expected them to return the same thing, but they\u2019re not the same. One acts on the whole value, and one acts on each bit at once.<\/p>\n<p>Actually, \u2018and\u2019 sees the value on the left. If it has a True Boolean value, it returns whatever value is on the right.<\/p>\n<p>Otherwise, it returns False. So, here, 5 and 7 is the same as True and 7. Hence, it returns 7.<\/p>\n<p>However, 5&amp;7 is the same as 101&amp;111. This results in 101, which is binary for 5. Let\u2019s look at each of these operators bit by bit (pun intended).<\/p>\n<p>Let&#8217;s move ahead with next Python Bitwise Operator<\/p>\n<h3>1. Python Bitwise AND (&amp;) Operator<\/h3>\n<p>1 has a Boolean value of True, and 0 has that of False. Take a look at the following code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; True\/2<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">0.5<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; False*2<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">0<\/div>\n<p>This proves something. Now, the binary and (&amp;) takes two values and performs an AND-ing on each pair of bits.<\/p>\n<p>Let\u2019s take an example.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 4 &amp; 8<\/pre>\n<p>Binary for 4 is 0100, and that for 8 is 1000. So when we AND the corresponding bits, it gives us 0000, which is binary for 0. Hence, the output.<\/p>\n<p>The following are the values when &amp;-ing 0 and 1.<\/p>\n<h4><strong>Python Bitwise Operators &#8211; AND Operators<\/strong><\/h4>\n<table>\n<tbody>\n<tr>\n<td width=\"312\">0 &amp; 0<\/td>\n<td width=\"312\">0<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">0 &amp; 1<\/td>\n<td width=\"312\">0<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">1 &amp; 0<\/td>\n<td width=\"312\">0<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">1 &amp; 1<\/td>\n<td width=\"312\">1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As you can see, an &amp;-ing returns 1 only if both bits are 1.<\/p>\n<p>You cannot, however, &amp; strings.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; '$'&amp;'%'<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p>Traceback (most recent call last):File &#8220;&lt;pyshell#30&gt;&#8221;, line 1, in &lt;module&gt;&#8217;$&#8217;&amp;&#8217;%&#8217;<\/p>\n<p>TypeError: unsupported operand type(s) for &amp;: &#8216;str&#8217; and &#8216;str&#8217;<\/p>\n<\/div>\n<p>Since Boolean values True and False have equivalent integer values of 1 and 0, we can &amp; them.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; False&amp;True<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">False<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; True&amp;True<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<p>Let\u2019s try a few more combinations.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 1&amp;True<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">1<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 1.0&amp;1.0<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p>Traceback (most recent call last):File &#8220;&lt;pyshell#36&gt;&#8221;, line 1, in &lt;module&gt;1.0&amp;1.0<\/p>\n<p>TypeError: unsupported operand type(s) for &amp;: &#8216;float&#8217; and &#8216;float&#8217;<\/p>\n<\/div>\n<p>You can also type your numbers directly in binary, as we discussed in section 6a in our Python Numbers tutorial.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 0b110 &amp; 0b101<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">4<\/div>\n<p>Here, 110 is binary for 6, and 101 for 5. &amp;-ing them, we get 100, which is binary for 4.<\/p>\n<h3>2. Python Bitwise OR (|) Operators<\/h3>\n<p>Now let&#8217;s discuss Python Bitwise OR (|) Operator<\/p>\n<p>Compared to &amp;, this one returns 1 even if one of the two corresponding bits from the two operands is 1.<\/p>\n<h4><strong>Python Bitwise Operators &#8211; OR Operators<\/strong><\/h4>\n<table>\n<tbody>\n<tr>\n<td width=\"312\">0|0<\/td>\n<td width=\"312\">0<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">0|1<\/td>\n<td width=\"312\">1<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">1|0<\/td>\n<td width=\"312\">1<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">1|1<\/td>\n<td width=\"312\">1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 6|1<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">7<\/div>\n<p>This is the same as the following.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 0b110|0b001<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">7<\/div>\n<p>Let\u2019s see some more examples.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; True|False<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<p>Let&#8217;s move to another Python Bitwise Operator<\/p>\n<h3>3. Python Bitwise XOR (^) Operator<\/h3>\n<p>XOR (eXclusive OR) returns 1 if one operand is 0 and another is 1. Otherwise, it returns 0. It is handy for quick swaps or checksums.<\/p>\n<h4><strong>Python Bitwise Operators &#8211; XOR Operators<\/strong><\/h4>\n<table>\n<tbody>\n<tr>\n<td width=\"312\">0^0<\/td>\n<td width=\"312\">0<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">0^1<\/td>\n<td width=\"312\">1<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">1^0<\/td>\n<td width=\"312\">1<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">1^1<\/td>\n<td width=\"312\">0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Let\u2019s take a few examples.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 6^6<\/pre>\n<p>Here, this is the same as 0b110^0b110. This results in 0b000, which is binary for 0.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 6^0<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">6<\/div>\n<p>This is equivalent to 0b110^0b000, which gives us 0b110. This is binary for 6.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 6^3<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">5<\/div>\n<p>Here, 0b110^0b011 gives us 0b101, which is binary for 5.<\/p>\n<p>Now let&#8217;s discuss Bitwise 1&#8217;s Complement (~)<\/p>\n<h3>4. Python Bitwise 1\u2019s Complement (~)<\/h3>\n<p>This one is a bit different from what we\u2019ve studied so far. This operator takes a number\u2019s binary, and returns its one\u2019s complement.<\/p>\n<p>For this, it flips the bits until it reaches the first 0 from right. ~x is the same as -x-1.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; ~2<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">-3<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; bin(2)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;0b10&#8217;<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; bin(-3)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;-0b11&#8217;<\/div>\n<p>To make it clear, we mention the binary values of both. Another example follows.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; ~45<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">-46<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; bin(45)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;0b101101&#8217;<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; bin(-46)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;-0b101110&#8217;<\/div>\n<h3>5. Python Bitwise Left-Shift Operator (&lt;&lt;)<\/h3>\n<p>Finally, we arrive at left-shift and right-shift operators. The left-shift operator shifts the bits of the number by the specified number of places.<\/p>\n<p>This means it adds 0s to the empty least-significant places now. Let\u2019s begin with an unusual example.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; True&lt;&lt;2<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">4<\/div>\n<p>Here, True has an equivalent integer value of 1. If we shift it by two places to the left, we get 100. This is binary for 4.<\/p>\n<p>Now let\u2019s do it on integers.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 2&lt;&lt;1<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">4<\/div>\n<p>10 shifted by one place to the left gives us 100, which is, again, 4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 3&lt;&lt;2<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">12<\/div>\n<p>Now, 11 shifted to the left by two places gives us 1100, which is binary for 12.<\/p>\n<p>Now let&#8217;s move to Next Python Bitwise Operator<\/p>\n<h3>6. Python Bitwise Right-Shift Operator (&gt;&gt;)<\/h3>\n<p>Now we\u2019ll see the same thing for right-shift. It shifts the bits to the right by the specified number of places.<\/p>\n<p>This means that those many bits are lost now.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 3&gt;&gt;1<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">1<\/div>\n<p>3 has a binary value of 11, which shifted one place to the right returns 1. But before closing on this tutorial, we\u2019ll take one last example.<\/p>\n<p>Let\u2019s check what\u2019s the decimal value for 11111.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; int(0b11111)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">31<\/div>\n<p>Now, let\u2019s shift it three places to the right.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 31&gt;&gt;3<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">3<\/div>\n<p>As you can see, it gives us 3, whose binary is 11. Makes sense, doesn\u2019t it?<\/p>\n<p>This was all about the Python Bitwise Operators.<\/p>\n<h3>Python Interview Questions on Bitwise Operators<\/h3>\n<p>1. What is the purpose of Python Bitwise Operator?<\/p>\n<p>2. Explain Python Bitwise Operator with an example?<\/p>\n<p>3. Are Python Bitwise Operators faster?<\/p>\n<p>4. What is Bitwise Not Operator?<\/p>\n<p>5. Where are Python Bitwise Operators used?<\/p>\n<h3>Conclusion<\/h3>\n<p>Although bitwise work sounds tough, Python makes it simple. You can see each step with bin() to show the binary form. By practicing small examples like 5 &amp; 3 or 12 &lt;&lt; 2, you build an instinct for how data moves at the lowest level. That skill is gold when speed, memory, or hardware control matters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this Python Bitwise Operators Tutorial, we will discuss Python Bitwise AND, OR, XOR, Left-shift, Right-shift, and 1&#8217;s complement Bitwise Operators in Python Programming. Along with this, we will discuss syntax and examples of&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":35911,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[36637,2010,36635,10390,10744,36636],"class_list":["post-5911","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-and-or-xor-operators-in-python","tag-bitwise-operator-in-python","tag-left-shift-operator-in-python","tag-python-bitwise-operator","tag-python-operators","tag-right-shift-operator-in-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Bitwise Operators with Syntax and Example - DataFlair<\/title>\n<meta name=\"description\" content=\"Bitwise Operators in Python take one to two operands, and operate on it\/them bit by bit, instead of whole.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Bitwise Operators with Syntax and Example - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Bitwise Operators in Python take one to two operands, and operate on it\/them bit by bit, instead of whole.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-13T00:10:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-28T05:32:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Bitwise Operators with Syntax and Example - DataFlair","description":"Bitwise Operators in Python take one to two operands, and operate on it\/them bit by bit, instead of whole.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/","og_locale":"en_US","og_type":"article","og_title":"Python Bitwise Operators with Syntax and Example - DataFlair","og_description":"Bitwise Operators in Python take one to two operands, and operate on it\/them bit by bit, instead of whole.","og_url":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-01-13T00:10:01+00:00","article_modified_time":"2026-04-28T05:32:03+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-1.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Bitwise Operators with Syntax and Example","datePublished":"2018-01-13T00:10:01+00:00","dateModified":"2026-04-28T05:32:03+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/"},"wordCount":1064,"commentCount":9,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-1.jpg","keywords":["and or xor operators in python","bitwise operator in python","left shift operator in python","python bitwise operator","python operators","right shift operator in python"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/","url":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/","name":"Python Bitwise Operators with Syntax and Example - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-1.jpg","datePublished":"2018-01-13T00:10:01+00:00","dateModified":"2026-04-28T05:32:03+00:00","description":"Bitwise Operators in Python take one to two operands, and operate on it\/them bit by bit, instead of whole.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Bitwise-Operators-in-Python-1.jpg","width":1200,"height":628,"caption":"Python Bitwise Operators with Syntax and Example"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-bitwise-operators\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Bitwise Operators with Syntax and Example"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=5911"}],"version-history":[{"count":18,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5911\/revisions"}],"predecessor-version":[{"id":147973,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5911\/revisions\/147973"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/35911"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=5911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=5911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=5911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}