{"id":114069,"date":"2025-12-10T11:59:22","date_gmt":"2025-12-10T06:29:22","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/?page_id=114069"},"modified":"2025-12-09T18:28:39","modified_gmt":"2025-12-09T12:58:39","slug":"python-bitwise-operators","status":"publish","type":"page","link":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/","title":{"rendered":"Python Bitwise Operators\u00a0"},"content":{"rendered":"\n<h1 id=\"python-bitwise-operators\">Python Bitwise Operators (&, |, ^, ~, <<, >>)<\/h1>\n\n<h2 id=\"what-are-bitwise-operators\">What Are Bitwise Operators?<\/h2>\n<p>\n    Python Bitwise operators perform operations on the binary representations of integers. Instead of working with the decimal numbers you see (like 10 or 5), these operators work on the underlying bits (zeros and ones).\n<\/p>\n\n<h3 id=\"prerequisite-understanding-binary\">Prerequisite: Understanding Binary<\/h3>\n<p>\n    Computers store integers as sequences of bits. To understand these operators, you must visualize the numbers in binary. To learn better, understand <a href=\"https:\/\/www.mygreatlearning.com\/blog\/how-to-convert-binary-to-decimal\/\">binary to decimal conversion<\/a>.\n<\/p>\n<div style=\"background-color: #f4f4f4; padding: 15px; border-radius: 5px; font-family: monospace; margin-bottom: 20px;\">\n    Decimal: 10<br>\n    Binary: 1010 (8 + 0 + 2 + 0)<br><br>\n    Decimal: 4<br>\n    Binary: 0100 (0 + 4 + 0 + 0)\n<\/div>\n<p>\n    You will rarely use bitwise operators for general logic (like normal if statements). We use them primarily for working with flags, permissions systems, binary protocols, and mathematical optimizations.\n<\/p>\n<h2 id=\"1-bitwise-and\">1. Bitwise AND (&)<\/h2>\n<p>\n    The AND operator compares two bits. The result is <code>1<\/code> only if both corresponding bits are <code>1<\/code>. Otherwise, the result is <code>0<\/code>.\n<\/p>\n<p><strong>Logic:<\/strong><\/p>\n<ul>\n    <li>1 & 1 = 1<\/li>\n    <li>1 & 0 = 0<\/li>\n    <li>0 & 1 = 0<\/li>\n    <li>0 & 0 = 0<\/li>\n<\/ul>\n\n<h3 id=\"syntax-and-examples\">Syntax and Examples<\/h3>\n<div class=\"code-editor-container\">\n    <div id=\"editor-bitwise-and\" class=\"python-code-editor\">\na = 10        # Binary: 1010\nb = 4         # Binary: 0100\n\nresult = a & b\n\n# Operation:\n#   1010  (10)\n# & 0100  (4)\n# ------\n#   0000  (0)\n\nprint(f\"Result of 10 & 4 is: {result}\")\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-bitwise-and', 'output-bitwise-and')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-bitwise-and', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-bitwise-and\" class=\"code-solution\">\n        <pre><code>a = 10\nb = 4\nresult = a & b\nprint(f\"Result of 10 & 4 is: {result}\")<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-bitwise-and\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-bitwise-and\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"2-bitwise-or\">2. Bitwise OR (|)<\/h2>\n<p>\n    The OR operator compares two bits. The result is <code>1<\/code> if at least one of the corresponding bits is <code>1<\/code>.\n<\/p>\n<p><strong>Logic:<\/strong><\/p>\n<ul>\n    <li>1 | 1 = 1<\/li>\n    <li>1 | 0 = 1<\/li>\n    <li>0 | 1 = 1<\/li>\n    <li>0 | 0 = 0<\/li>\n<\/ul>\n\n<h3 id=\"syntax-and-examples\">Syntax and Examples<\/h3>\n<div class=\"code-editor-container\">\n    <div id=\"editor-bitwise-or\" class=\"python-code-editor\">\na = 10        # Binary: 1010\nb = 4         # Binary: 0100\n\nresult = a | b\n\n# Operation:\n#   1010  (10)\n# | 0100  (4)\n# ------\n#   1110  (14)\n\nprint(f\"Result of 10 | 4 is: {result}\")\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-bitwise-or', 'output-bitwise-or')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-bitwise-or', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-bitwise-or\" class=\"code-solution\">\n        <pre><code>a = 10\nb = 4\nresult = a | b\nprint(f\"Result of 10 | 4 is: {result}\")<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-bitwise-or\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-bitwise-or\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"3-bitwise-xor\">3. Bitwise XOR (^)<\/h2>\n<p>\n    XOR stands for \"Exclusive OR\". The result is <code>1<\/code> only if the corresponding bits are different. If they are the same (both 0 or both 1), the result is <code>0<\/code>.\n<\/p>\n<p><strong>Logic:<\/strong><\/p>\n<ul>\n    <li>1 ^ 1 = 0<\/li>\n    <li>1 ^ 0 = 1<\/li>\n    <li>0 ^ 1 = 1<\/li>\n    <li>0 ^ 0 = 0<\/li>\n<\/ul>\n\n<h3 id=\"syntax-and-examples\">Syntax and Examples<\/h3>\n<div class=\"code-editor-container\">\n    <div id=\"editor-bitwise-xor\" class=\"python-code-editor\">\na = 10        # Binary: 1010\nb = 4         # Binary: 0100\n\nresult = a ^ b\n\n# Operation:\n#   1010  (10)\n# ^ 0100  (4)\n# ------\n#   1110  (14)\n\nprint(f\"Result of 10 ^ 4 is: {result}\")\n# Note: In this case, result matches OR, but logic is distinct.\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-bitwise-xor', 'output-bitwise-xor')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-bitwise-xor', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-bitwise-xor\" class=\"code-solution\">\n        <pre><code>a = 10\nb = 4\nresult = a ^ b\nprint(f\"Result of 10 ^ 4 is: {result}\")<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-bitwise-xor\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-bitwise-xor\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"4-bitwise-not\">4. Bitwise NOT (~)<\/h2>\n<p>\n    The NOT operator is a unary operator, meaning it works on a single number. It inverts all the bits: <code>0<\/code> becomes <code>1<\/code>, and <code>1<\/code> becomes <code>0<\/code>.\n<\/p>\n<p>\n    <strong>Important Note on Output:<\/strong> Python uses \"Two's Complement\" to represent signed integers. In Two's Complement, the result of <code>~x<\/code> is mathematically equal to <code>-x - 1<\/code>.\n<\/p>\n\n<h3 id=\"syntax-and-examples\">Syntax and Examples<\/h3>\n<div class=\"code-editor-container\">\n    <div id=\"editor-bitwise-not\" class=\"python-code-editor\">\na = 10        # Binary: ...00001010\n\nresult = ~a\n\n# Operation:\n# Bits are inverted. \n# Mathematically: -10 - 1 = -11\n\nprint(f\"Result of ~10 is: {result}\")\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-bitwise-not', 'output-bitwise-not')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-bitwise-not', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-bitwise-not\" class=\"code-solution\">\n        <pre><code>a = 10\nresult = ~a\nprint(f\"Result of ~10 is: {result}\")<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-bitwise-not\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-bitwise-not\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"5-bitwise-left-shift\">5. Bitwise Left Shift (<<)<\/h2>\n<p>\n    This operator shifts the bits of the first operand to the left by the number of places specified by the second operand. New bits on the right are filled with zeros.\n<\/p>\n<p><strong>Effect:<\/strong> Shifting left by 1 is equivalent to multiplying the number by 2.<\/p>\n\n<h3 id=\"syntax-and-examples\">Syntax and Examples<\/h3>\n<div class=\"code-editor-container\">\n    <div id=\"editor-left-shift\" class=\"python-code-editor\">\na = 10        # Binary: 0000 1010\nshift_by = 2\n\nresult = a << shift_by\n\n# Operation:\n# Original:   0000 1010\n# Shift left: 0010 1000  (The '1010' moved two spots left)\n# Decimal:    32 + 8 = 40\n\nprint(f\"Result of 10 << 2 is: {result}\")\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-left-shift', 'output-left-shift')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-left-shift', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-left-shift\" class=\"code-solution\">\n        <pre><code>a = 10\nshift_by = 2\nresult = a << shift_by\nprint(f\"Result of 10 << 2 is: {result}\")<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-left-shift\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-left-shift\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"6-bitwise-right-shift\">6. Bitwise Right Shift (>>)<\/h2>\n<p>\n    This operator shifts the bits of the first operand to the right by the number of places specified by the second operand. Bits that are shifted off the end are discarded.\n<\/p>\n<p><strong>Effect:<\/strong> Shifting right by 1 is equivalent to performing integer division by 2.<\/p>\n\n<h3 id=\"syntax-and-examples\">Syntax and Examples<\/h3>\n<div class=\"code-editor-container\">\n    <div id=\"editor-right-shift\" class=\"python-code-editor\">\na = 10        # Binary: 1010\nshift_by = 1\n\nresult = a >> shift_by\n\n# Operation:\n# Original:    1010\n# Shift right: 0101 (The last '0' is discarded)\n# Decimal:     5\n\nprint(f\"Result of 10 >> 1 is: {result}\")\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-right-shift', 'output-right-shift')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-right-shift', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-right-shift\" class=\"code-solution\">\n        <pre><code>a = 10\nshift_by = 1\nresult = a >> shift_by\nprint(f\"Result of 10 >> 1 is: {result}\")<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-right-shift\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-right-shift\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"when-to-use-logical-vs-bitwise-operators\">When to Use Logical vs. Bitwise Operators<\/h2>\n<p>\nUse bitwise operators to manipulate individual bits in integers, flags, or low-level data. They work for tasks like masking, shifting, and bit-level optimization. Use logical operators to combine boolean conditions in control flow (e.g., if, while statements) or simplify logical expressions.\n<\/p>\n\n<h2 id=\"summary-table\">Summary Table<\/h2>\n<div style=\"overflow-x: auto; margin-bottom: 20px;\">\n    <table style=\"width: 100%; border-collapse: collapse; min-width: 600px;\">\n        <thead>\n            <tr style=\"background-color: #f4f4f4;\">\n                <th style=\"border: 1px solid #ddd; padding: 12px; text-align: left;\">Operator<\/th>\n                <th style=\"border: 1px solid #ddd; padding: 12px; text-align: left;\">Name<\/th>\n                <th style=\"border: 1px solid #ddd; padding: 12px; text-align: left;\">Description<\/th>\n                <th style=\"border: 1px solid #ddd; padding: 12px; text-align: left;\">Example<\/th>\n            <\/tr>\n        <\/thead>\n        <tbody>\n            <tr>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>&<\/code><\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">AND<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">Sets bit to 1 if both bits are 1<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>5 & 3<\/code><\/td>\n            <\/tr>\n            <tr>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>|<\/code><\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">OR<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">Sets bit to 1 if either bit is 1<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>5 | 3<\/code><\/td>\n            <\/tr>\n            <tr>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>^<\/code><\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">XOR<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">Sets bit to 1 if bits are different<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>5 ^ 3<\/code><\/td>\n            <\/tr>\n            <tr>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>~<\/code><\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">NOT<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">Inverts the bits<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>~5<\/code><\/td>\n            <\/tr>\n            <tr>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code><<<\/code><\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">Left Shift<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">Shifts bits left (multiplies by 2)<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>5 << 1<\/code><\/td>\n            <\/tr>\n            <tr>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>>><\/code><\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">Right Shift<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\">Shifts bits right (divides by 2)<\/td>\n                <td style=\"border: 1px solid #ddd; padding: 12px;\"><code>5 >> 1<\/code><\/td>\n            <\/tr>\n        <\/tbody>\n    <\/table>\n<\/div>\n\n\n<div class=\"cta-final\">\n    <div class=\"cta-final-header\">\n        <span class=\"cta-final-trophy\">\ud83c\udfc6<\/span>\n        <h2 id=\"lesson-completed\">Lesson Completed<\/h2>\n    <\/div>\n\n    <p class=\"cta-final-intro\">\n        You have successfully learned about the six Bitwise Operators in Python, how they manipulate binary data, and their mathematical effects.\n    <\/p>\n\n    <div class=\"cta-final-grid\">\n        <div class=\"cta-final-option\">\n            <div class=\"cta-final-option-header\">\n                <span>\ud83d\udcd8<\/span>\n                <h4 id=\"full-python-course\">Full Python Course<\/h4>\n            <\/div>\n            <p>Master Python with 11+ hours of content, 50+ exercises, and real-world projects.<\/p>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-python-programming?utm_source=blog\" class=\"cta-final-button-primary\">Enroll Now<\/a>\n        <\/div>\n\n        <div class=\"cta-final-option\" id=\"pt-next-lesson-container\">\n            <div class=\"cta-final-option-header\">\n                <span>\ud83d\udcdd<\/span>\n                <h4 id=\"next-lesson\">Next Lesson<\/h4>\n            <\/div>\n            <p id=\"pt-next-lesson-text\">Continue with the next lesson on Python Sets and Booleans.<\/p>\n            <a href=\"#\" id=\"pt-next-lesson-button\" class=\"cta-final-button-secondary\">Next Lesson -><\/a>\n        <\/div>\n    <\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python Bitwise Operators (&#038;, |, ^, ~, ) What Are Bitwise Operators? Python Bitwise operators perform operations on the binary representations of integers. Instead of working with the decimal numbers you see (like 10 or 5), these operators work on the underlying bits (zeros and ones). Prerequisite: Understanding Binary Computers store integers as sequences of [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":114124,"parent":113156,"menu_order":20,"comment_status":"closed","ping_status":"closed","template":"templates\/python-tutorial.php","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36796,36893],"class_list":["post-114069","page","type-page","status-publish","has-post-thumbnail","hentry","category-software","tag-python","tag-python-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Bitwise Operators\u00a0<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/python\/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\u00a0\" \/>\n<meta property=\"og:description\" content=\"Python Bitwise Operators (&amp;, |, ^, ~, ) What Are Bitwise Operators? Python Bitwise operators perform operations on the binary representations of integers. Instead of working with the decimal numbers you see (like 10 or 5), these operators work on the underlying bits (zeros and ones). Prerequisite: Understanding Binary Computers store integers as sequences of [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1097\" \/>\n\t<meta property=\"og:image:height\" content=\"624\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Python Bitwise Operators\u00a0\",\"datePublished\":\"2025-12-10T06:29:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/\"},\"wordCount\":503,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/12\\\/python-bitwise-operators.webp\",\"keywords\":[\"python\",\"python-tutorial\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/\",\"name\":\"Python Bitwise Operators\u00a0\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/12\\\/python-bitwise-operators.webp\",\"datePublished\":\"2025-12-10T06:29:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/12\\\/python-bitwise-operators.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/12\\\/python-bitwise-operators.webp\",\"width\":1097,\"height\":624,\"caption\":\"Python Bitwise Operators\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-bitwise-operators\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Tutorial\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Bitwise Operators\u00a0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Bitwise Operators\u00a0","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:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/","og_locale":"en_US","og_type":"article","og_title":"Python Bitwise Operators\u00a0","og_description":"Python Bitwise Operators (&, |, ^, ~, ) What Are Bitwise Operators? Python Bitwise operators perform operations on the binary representations of integers. Instead of working with the decimal numbers you see (like 10 or 5), these operators work on the underlying bits (zeros and ones). Prerequisite: Understanding Binary Computers store integers as sequences of [&hellip;]","og_url":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","og_image":[{"width":1097,"height":624,"url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_site":"@Great_Learning","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Python Bitwise Operators\u00a0","datePublished":"2025-12-10T06:29:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/"},"wordCount":503,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp","keywords":["python","python-tutorial"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/","url":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/","name":"Python Bitwise Operators\u00a0","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp","datePublished":"2025-12-10T06:29:22+00:00","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp","width":1097,"height":624,"caption":"Python Bitwise Operators"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-bitwise-operators\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Tutorial","item":"https:\/\/www.mygreatlearning.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Bitwise Operators\u00a0"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp",1097,624,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators-150x150.webp",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators-300x171.webp",300,171,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators-768x437.webp",768,437,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators-1024x582.webp",1024,582,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp",1097,624,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators.webp",1097,624,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators-640x624.webp",640,624,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/12\/python-bitwise-operators-150x85.webp",150,85,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Python Bitwise Operators (&, |, ^, ~, ) What Are Bitwise Operators? Python Bitwise operators perform operations on the binary representations of integers. Instead of working with the decimal numbers you see (like 10 or 5), these operators work on the underlying bits (zeros and ones). Prerequisite: Understanding Binary Computers store integers as sequences of&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/114069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=114069"}],"version-history":[{"count":11,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/114069\/revisions"}],"predecessor-version":[{"id":114126,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/114069\/revisions\/114126"}],"up":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/114124"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=114069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=114069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=114069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}