<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4732,"date":"2022-08-17T11:05:32","date_gmt":"2022-08-17T11:05:32","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4732"},"modified":"2022-08-17T11:07:01","modified_gmt":"2022-08-17T11:07:01","slug":"what-is-an-operator-in-python","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/","title":{"rendered":"What is an operator in Python ?"},"content":{"rendered":"<ul>\n<li>In python operators are generally used to perform operations on variables and values.<\/li>\n<li>In specific programming language operators are the pillars of a program on which the logic is built.<\/li>\n<li>Python operator consists of different types, they are\n<ul>\n<li>Arithmetic operators<\/li>\n<li>Comparison operators<\/li>\n<li>Assignment operators<\/li>\n<li>Logical operators<\/li>\n<li>Bitwise operators<\/li>\n<li>Membership operators<\/li>\n<li>Identity operators<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4733 aligncenter\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png\" alt=\"\" width=\"1460\" height=\"602\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png 1460w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators-300x124.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators-1024x422.png 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators-768x317.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators-390x161.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators-820x338.png 820w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators-1180x487.png 1180w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><\/p>\n<h2 id=\"arithmetic-operators\">Arithmetic operators<\/h2>\n<ul>\n<li>Arithmetic operators are used to perform arithmetic operations between two operands and it includes + (addition), &#8211; (subtraction), * (multiplication), \/ (divide), % (reminder), \/\/ (floor division) and exponent (**) operators.\n<ul style=\"text-align: justify;\">\n<li><strong>+ (addition)<\/strong> operator is used to add two operands.<\/li>\n<li><strong>&#8211; (Subtraction)<\/strong> operator is used to subtract the second operand from the first operand then if the first operand is less than the second operand, the value results negative.<\/li>\n<li><strong>\/ (divide)<\/strong> returns the quotient after dividing the first operand by the second operand.<\/li>\n<li><strong>* (multiplication)<\/strong> is used to multiply one operand with the other.<\/li>\n<li><strong>% (reminder) <\/strong>returns the reminder after dividing the first operand by the second operand.<\/li>\n<li><strong>**(Exponent)<\/strong> is an exponent operator represented as it calculates the first operand power to the second operand.<\/li>\n<li><strong>\/\/ (Floor division)<\/strong> operator gives the floor value of the quotient produced by dividing the two operands.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"comparison-operators\">Comparison operators<\/h2>\n<ul>\n<li>It is used to comparing the value of the two operands and returns Boolean true or false accordingly.\n<ul style=\"text-align: justify;\">\n<li><strong>(= =)<\/strong> If the value of two operands is equal, then the condition becomes true.<\/li>\n<li><strong>(! =)<\/strong> if the value of two operands is not equal, then the condition becomes true.<\/li>\n<li><strong>(&lt; =)<\/strong> If the first operand is less than or equal to the second operand, then the condition becomes true.<\/li>\n<li><strong>(&gt; =)<\/strong> if the first operand is greater than or equal to the second operand, then the condition becomes true.<\/li>\n<li><strong>(&gt;)<\/strong> If the first operand is greater than the second operand, then the condition becomes true.<\/li>\n<li><strong>(&lt;)<\/strong> If the first operand is less than the second operand, then the condition becomes true.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"assignment-operators\">Assignment operators<\/h2>\n<ul>\n<li>It is used to assign the value of the right expression to the left operand.\n<ul style=\"text-align: justify;\">\n<li><strong>(=)<\/strong> It assigns the value of the right expression to the left operand.<\/li>\n<li><strong>(+=)<\/strong> It increases the value of the left operand by the value of the right operand and assigns the modified value back to left operand.<\/li>\n<li><strong>(-=)<\/strong> It increases the value of the left operand by the value of the right operand and assigns the modified value back to left operand.<\/li>\n<li><strong>(*=)<\/strong> It multiplies the value of the left operand by the value of the right operand and assigns the modified value back to then the left operand.<\/li>\n<li><strong>(%=)<\/strong> It divides the value of the left operand by the value of the right operand and assigns the reminder back to the left operand.<\/li>\n<li><strong>(**=)<\/strong> a**=b will be equal to a=a**b.<\/li>\n<li><strong>(\/\/=)<\/strong> A\/\/=b will be equal to a = a\/\/ b, for example, if a = 4, b = 3, a\/\/=b will assign 4\/\/3 = 1 to a.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"logical-operators\">Logical operators<\/h2>\n<ul>\n<li>In expression evaluation logical operators are used primarily to make a decision.\n<ul style=\"text-align: justify;\">\n<li><strong>\u201cand\u201d<\/strong> operator is used when both the expression is true, then the condition will be true. If a and b are the two expressions, a \u2192 true, b \u2192 true =&gt; a and b \u2192 true.<\/li>\n<li><strong>\u201cor\u201d<\/strong> operator is used when one of the expressions is true, then the condition will be true. In this a and b are the two expressions, a \u2192 true, b \u2192 false =&gt; a or b \u2192 true.<\/li>\n<li><strong>\u201cnot\u201d<\/strong> operator is used when an expression a is true, then not (a) will be false and vice versa.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"membership-operators\">Membership operators<\/h2>\n<ul>\n<li>It is used to check the membership of value inside a python data structure and if the value is present in the data structure, then the resulting value is true otherwise it returns false.\n<ul style=\"text-align: justify;\">\n<li><strong>\u201cin\u201d<\/strong> operator is evaluated to be true if the first operand is found in the second operand (list, tuple, or dictionary).<\/li>\n<li><strong>\u201cNot in\u201d<\/strong> operator is evaluated to be true if the first operand is not found in the second operand (list, tuple, or dictionary).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"identity-operators\">Identity operators<\/h2>\n<ul>\n<li>It is used to decide whether an element certain class or type.\n<ul style=\"text-align: justify;\">\n<li><strong>\u201cis\u201d<\/strong> operator is evaluated to be true if the reference present at both sides point to the same object.<\/li>\n<li><strong>\u201cIs not\u201d<\/strong> is evaluated to be true if the reference present at both sides do not point to the same object.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"bitwise-operators\">Bitwise operators<\/h2>\n<ul>\n<li>These operators perform bit by bit operation on the values of the two operands.\n<ul style=\"text-align: justify;\">\n<li><strong>\u201c&amp; (binary and)\u201d<\/strong> is used when both the bits at the same place in two operands are 1, then 1 is copied to the result. Otherwise, 0 is copied.<\/li>\n<li><strong>\u201c| (binary or)\u201d<\/strong> operator is used where the resulting bit will be 0 if both the bits are zero; otherwise, the resulting bit will be 1.<\/li>\n<li><strong>\u201c^ (binary xor)\u201d<\/strong> operator is used where the resulting bit will be 1 if both the bits are different; otherwise, the resulting bit will be 0.<\/li>\n<li><strong>\u201c~(negation)&#8221;<\/strong> operator calculates the negation of each bit of the operand, i.e., if the bit is 0, the resulting bit will be 1 and vice versa.<\/li>\n<li><strong>\u201c&lt;&lt; (left shift)\u201d<\/strong> operator is used where the left operand value is moved left by the number of bits present in the right operand.<\/li>\n<li><strong>\u201c&gt;&gt;(right shift)\u201d<\/strong> operator is used where the left operand value is moved right by the number of bits present in the right operand.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In python operators are generally used to perform operations on variables and values. In specific programming language operators are the pillars of a program on which the logic is built. Python operator consists of different types, they are Arithmetic operators Comparison operators Assignment operators Logical operators Bitwise operators Membership operators Identity operators Arithmetic operators Arithmetic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[5608],"tags":[18283,18272,18270,18274,18273,18282,18275,18284,18271,18276,5845,18269,18278,18280,18277,18279,18281],"class_list":["post-4732","post","type-post","status-publish","format-standard","hentry","category-python","tag-operator-in-python-list","tag-arithmetic-operators-in-python","tag-assignment-operator-in-python","tag-bitwise-operator-in-python","tag-comparison-operators-in-python","tag-does-python-have-operator","tag-identity-operators-in-python","tag-is-an-operator-in-python","tag-logical-operators-in-python","tag-python-operator-vs","tag-python-operator","tag-symbol-in-python","tag-what-is-an-assignment-operator-in-python","tag-what-is-an-identity-operator-in-python","tag-what-is-an-operator-in-python","tag-what-is-not-an-arithmetic-operator-in-python","tag-what-type-is-an-operator-in-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is an operator in Python ? - Python Operators - Wikitechy<\/title>\n<meta name=\"description\" content=\"What is an operator in Python ? - In python operators are generally used to perform operations on variables and values.\" \/>\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.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is an operator in Python ? - Python Operators - Wikitechy\" \/>\n<meta property=\"og:description\" content=\"What is an operator in Python ? - In python operators are generally used to perform operations on variables and values.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-17T11:05:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-17T11:07:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/\",\"name\":\"What is an operator in Python ? - Python Operators - Wikitechy\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png\",\"datePublished\":\"2022-08-17T11:05:32+00:00\",\"dateModified\":\"2022-08-17T11:07:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is an operator in Python ? - In python operators are generally used to perform operations on variables and values.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png\",\"width\":1460,\"height\":602},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is an operator in Python ? - Python Operators - Wikitechy","description":"What is an operator in Python ? - In python operators are generally used to perform operations on variables and values.","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.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/","og_locale":"en_US","og_type":"article","og_title":"What is an operator in Python ? - Python Operators - Wikitechy","og_description":"What is an operator in Python ? - In python operators are generally used to perform operations on variables and values.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/","og_site_name":"Wikitechy","article_published_time":"2022-08-17T11:05:32+00:00","article_modified_time":"2022-08-17T11:07:01+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/","name":"What is an operator in Python ? - Python Operators - Wikitechy","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png","datePublished":"2022-08-17T11:05:32+00:00","dateModified":"2022-08-17T11:07:01+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is an operator in Python ? - In python operators are generally used to perform operations on variables and values.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-an-operator-in-python\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/python-operators.png","width":1460,"height":602},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4732"}],"version-history":[{"count":2,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4732\/revisions"}],"predecessor-version":[{"id":4736,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4732\/revisions\/4736"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}