{"id":74599,"date":"2019-12-26T10:12:53","date_gmt":"2019-12-26T04:42:53","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=74599"},"modified":"2024-08-22T20:24:19","modified_gmt":"2024-08-22T14:54:19","slug":"python-operator-precedence","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/","title":{"rendered":"Python Operator Precedence &#8211; Learn how to perform operations in Python"},"content":{"rendered":"<p>There are many different types of operators. When evaluating complex expressions like <strong>5+2*4%6-1 and 13 or 3<\/strong> one might easily get confused about in which order the operations will be performed. This Python operator precedence article will help you in understanding how these expressions are <strong>evaluated<\/strong> and the <strong>order of precedence<\/strong> Python follows.<\/p>\n<h3>Python Operators Precedence Table<\/h3>\n<p>Here we have a table that is arranged in the ascending order of precedence of operators.<\/p>\n<p>The new <strong>Assignment expression (:=) operator<\/strong> from Python <strong>3.8<\/strong> onwards has the <strong>lowest precedence<\/strong> while <strong>parentheses()<\/strong> have the <strong>highest precedence<\/strong>.<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Operator<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">:=<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Assignment expression (Lowest precedence)\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">lambda<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Lambda expression<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">if-else<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Conditional expression<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">or<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Boolean OR<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">and<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Boolean AND<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">not<\/span> <span style=\"font-weight: 400;\">x<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Boolean NOT<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&lt;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&lt;=<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&gt;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&gt;=<\/span><span style=\"font-weight: 400;\">,\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Comparison operators<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">!=<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">==<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Equality operators<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">in<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">not in<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">is<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">is not<\/span><span style=\"font-weight: 400;\">,<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Identity operators, membership operators<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">|<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Bitwise OR<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">^<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Bitwise XOR<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&amp;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Bitwise AND<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">&lt;&lt;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&gt;&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Left and right Shifts<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">+<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&#8211;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Addition and subtraction<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">*<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">\/\/<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">%<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Multiplication, matrix multiplication, division, floor division, remainder<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">+x<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">-x<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">~x<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Unary plus, Unary minus, bitwise NOT<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">**<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Exponentiation<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">await<\/span> <span style=\"font-weight: 400;\">x<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Await expression<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">x[index]<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">x[index:index]<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">x(arguments&#8230;)<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">x.attribute<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Subscription, slicing, call, attribute reference<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">(expressions&#8230;)<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">[expressions&#8230;]<\/span><span style=\"font-weight: 400;\">, <\/span><\/p>\n<p><span style=\"font-weight: 400;\">{key: value&#8230;}<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">{expressions&#8230;}<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Binding or parenthesized expression, list display, dictionary display, set display<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Parentheses (Highest precedence)\u00a0<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>What are Expressions in Python?<\/h3>\n<p>Before we move further, let\u2019s first understand what are expressions.<\/p>\n<p>An expression is made with <strong>combinations of variables<\/strong>, <strong>values<\/strong>, <strong>operators<\/strong> and <strong>function calls. <\/strong>The Python interpreter <strong>evaluates<\/strong> the valid expression.<\/p>\n<p>Have a look at a very simple expression.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">5 - 2<\/pre>\n<p><strong>Output: <\/strong><\/p>\n<div class=\"code-output\">3<\/div>\n<p>5-2 is an expression that contains a <strong>single operator<\/strong>.<\/p>\n<p>However, an expression can also contain <strong>multiple operators<\/strong> and <strong>operands<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">10-5\/5<\/pre>\n<p><strong>Output: <\/strong><\/p>\n<div class=\"code-output\">9.0<\/div>\n<p>In this expression, it first <strong>divided<\/strong> the 5\/5 and then <strong>subtracted<\/strong> the result from 10 because, in Python, the division operator has <strong>higher precedence<\/strong> than subtraction.<\/p>\n<p>Let\u2019s look at this example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">(10-5)\/5<\/pre>\n<p><strong>Output: <\/strong><\/p>\n<div class=\"code-output\">1.0<\/div>\n<p>Here, with the use of <strong>parentheses<\/strong>, we force the interpreter to first evaluate the expression <strong>inside<\/strong> the parentheses and then continue the overall evaluation.<\/p>\n<h3>Python Operators Precedence Rule &#8211; PEMDAS<\/h3>\n<p>You might have heard about the <strong>BODMAS rule<\/strong> in your school&#8217;s mathematics class. Python also uses a similar type of rule known as <strong>PEMDAS<\/strong>.<\/p>\n<p><strong>P &#8211;<\/strong> Parentheses<br \/>\n<strong>E &#8211;<\/strong> Exponentiation<br \/>\n<strong>M &#8211;<\/strong> Multiplication<br \/>\n<strong>D &#8211;<\/strong> Division<br \/>\n<strong>A &#8211;<\/strong> Addition<br \/>\n<strong>S &#8211;<\/strong> Subtraction<\/p>\n<p>The precedence of operators is listed from <strong>High to low<\/strong>. To remember the abbreviations, we have a funny mnemonic <strong>\u201cPlease Excuse My Dear Aunt Sally\u201d<\/strong>.<a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/python-precedence-meme.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-74721 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/python-precedence-meme.jpg\" alt=\"python operator precedence\" width=\"476\" height=\"324\" \/><\/a><\/p>\n<p>Now we apply the PEMDAS rule and evaluate the following expression &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">((((6+4)*2)-10)\/\/2)-4*2<\/pre>\n<p><strong>Output: <\/strong><\/p>\n<div class=\"code-output\">-3.0<\/div>\n<p>How did we get -3?<\/p>\n<p>Let\u2019s break down the evaluation:<\/p>\n<p>(6+4) = 10<br \/>\n(10*2) = 20<br \/>\n(20-10) = 10<br \/>\n(10\/\/2) = 5<br \/>\n4*2 = 8<br \/>\n5-8 = -3<\/p>\n<h3>Associativity of Operators in Python<\/h3>\n<p>If you observed the precedence table, you may have noticed that many cells had <strong>more than one operator<\/strong> which means that they have the <strong>same precedence<\/strong>.<\/p>\n<p>So then, which will be evaluated first is managed by the <strong>associativity of operators<\/strong>.<\/p>\n<h4>1. Associative Operators<\/h4>\n<p>The associative operators are <strong>division<\/strong>, <strong>multiplication<\/strong>, <strong>remainder<\/strong>, etc. and the expressions will be evaluated from <strong>left to right<\/strong>. Almost all operators except the <strong>exponentiation(**) operator<\/strong> support left-to-right associativity.<\/p>\n<p>This means that in an expression with multiple associative operators of the same precedence, the operations are performed sequentially from left to right, ensuring consistent and predictable results.<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<p>Suppose <strong>modulus(%)<\/strong> and<strong> division(\/)<\/strong> <strong>operators<\/strong> have the <strong>same precedence<\/strong>. So, if both operators are present in an expression, then the <strong>left one<\/strong> is evaluated <strong>first<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">45 % 10 \/ 2<\/pre>\n<p><strong>Output: <\/strong><\/p>\n<div class=\"code-output\">2.5<\/div>\n<p>First, 45%10 gives 5 and then 5\/2 gives us 2.5 as output. If this was evaluated from right to left, we would get a <strong>different<\/strong> output.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">45% (10\/2)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0.0<\/div>\n<p>Here, we <strong>forced<\/strong> the expression to evaluate from right to left.<\/p>\n<p><strong>Example 2:<\/strong><\/p>\n<p>The <strong>exponentiation operator<\/strong> evaluates from right to left.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">2**2**3<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">256<\/div>\n<p>If we want to see the output of left to right, we can use <strong>parentheses<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">(2**2)**3<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">64<\/div>\n<h4>2. Non-Associative Operators<\/h4>\n<p>The comparison operator and the assignment operators do not support <strong>associativity<\/strong> which means that an expression like <strong>10&lt;20&lt;30<\/strong> doesn\u2019t mean<strong> (10&lt;20)&lt;30<\/strong> or <strong>10&lt;(20&lt;30 )<\/strong>. They both mean the same thing as they are evaluated from <strong>left to right<\/strong>. This ensures logical evaluation without ambiguity.<\/p>\n<p>The statement <strong>10&lt;20&lt;30<\/strong> means<strong> 10&lt;20<\/strong> and <strong>20&lt;30<\/strong>. You can also chain the assignment operators in any order and they will behave the same way.<\/p>\n<p><strong>a = b = c = d<\/strong> will be same as<strong> b = a = d = c<\/strong> or <strong>d = c = b = a<\/strong>.<\/p>\n<h3>Short-Circuiting in Python Operators Precedence<\/h3>\n<p>As we saw how Python mostly evaluates the expression from <strong>left-to-right<\/strong>.<\/p>\n<p>In expression with <strong>\u2018and\u2019<\/strong>, <strong>\u2018or\u2019<\/strong> <strong>operators<\/strong>, Python uses <strong>Short-Circuiting<\/strong> which means that it will evaluate the right side only when it is <strong>needed<\/strong>.<\/p>\n<p>You\u2019ll understand this better with examples.<\/p>\n<h4>1. Short-circuiting with and\/or<\/h4>\n<p>The <strong>boolean operation<\/strong> will stop executing when we arrive at the truth value of the expression.<\/p>\n<ul>\n<li>x or y: Evaluates y only when x is false.<\/li>\n<li>x and y: Evaluates y only when x is true.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">0 or \u201cHey\u201d and 1<\/pre>\n<p><strong>Output:\u00a0<\/strong><\/p>\n<div class=\"code-output\">1<\/div>\n<p>0 or \u201cHey\u201d returns \u201cHey\u201d<br \/>\n\u201cHey\u201d and 1 returns 1<\/p>\n<h4>2. Short-circuiting with all()\/ any()<\/h4>\n<p>The inbuilt functions <strong>all()<\/strong> and <strong>any()<\/strong> also <strong>supports short-circuiting<\/strong>.<\/p>\n<ul>\n<li><strong>all()<\/strong> function checks that all statements should be \u2018True\u2019.<\/li>\n<li>So when the first \u2018False\u2019 statement occurs, it <strong>stops<\/strong> further executing and returns <strong>False<\/strong>.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def short_ciruit(i):\r\n  print(\u201cExecuting\u201d)\r\n  return i\r\n\r\nprint(all(short_circuit(i) for i in [1,2,3,0,5,6] ) )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Executing<br \/>\nExecuting<br \/>\nExecuting<br \/>\nExecuting<br \/>\nFalse<\/div>\n<ul>\n<li><strong>any()<\/strong> function returns \u201cTrue\u201d if one of the statements is true.<\/li>\n<li>So, when the first \u2018True\u2019 statement occurs, we don\u2019t need to <strong>execute<\/strong> any further and simply return <strong>\u201cTrue\u201d<\/strong>.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def short_ciruit(i):\r\n  print(\u201cExecuting\u201d)\r\n  return i\r\n\r\nprint(any(short_circuit(i) for i in [0,0,3,0,5,6] ) )<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Executing<br \/>\nExecuting<br \/>\nExecuting<br \/>\nTrue<\/div>\n<h4>3. Short-circuiting with conditional operators<\/h4>\n<p><strong>Conditional operators<\/strong> also follow short-circuiting. Let\u2019s see it with an example.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def check(i)\r\n    \"Watch how this unfurls with conditional operators like &gt; and &lt;.\r\n     Have a look at Python Bitwise Operator\"\r\n     return i\r\n\r\nprint(5&gt;20&gt;check(50))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">False<\/div>\n<p>The statement stopped executing when the statement becomes false and it was no longer needed to execute it further so the <strong>check(50) method<\/strong> didn\u2019t run.<\/p>\n<h3>Summary<\/h3>\n<p>In this article, we studied the important topic of Python <strong>operators precedence table<\/strong>. We understood the rules of operator precedence and how Python evaluates complex expressions. Some operators are <strong>associative<\/strong> while some are <strong>non-associative<\/strong>.<\/p>\n<p>Later on, we saw more on <strong>short-circuiting<\/strong> that Python stops executing when it is sure of the result and thus it doesn\u2019t need to execute code any further.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many different types of operators. When evaluating complex expressions like 5+2*4%6-1 and 13 or 3 one might easily get confused about in which order the operations will be performed. This Python operator&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":74720,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[1142,1144,1115,1146,1148,1150],"class_list":["post-74599","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-associativity-of-operators-in-python","tag-operator-precedence-in-python","tag-python-operator-precedence","tag-python-operator-precedence-table","tag-python-rules","tag-what-are-expressions-in-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Operator Precedence - Learn how to perform operations in Python - TechVidvan<\/title>\n<meta name=\"description\" content=\"Python Operator Precedence - Explore precedence table in Python, expressions in Python, PEMDAS\u00a0rule, Short-Circuiting in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Operator Precedence - Learn how to perform operations in Python - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Python Operator Precedence - Explore precedence table in Python, expressions in Python, PEMDAS\u00a0rule, Short-Circuiting in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-26T04:42:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-22T14:54:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/Python-operator-precedence-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Operator Precedence - Learn how to perform operations in Python - TechVidvan","description":"Python Operator Precedence - Explore precedence table in Python, expressions in Python, PEMDAS\u00a0rule, Short-Circuiting in Python.","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:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/","og_locale":"en_US","og_type":"article","og_title":"Python Operator Precedence - Learn how to perform operations in Python - TechVidvan","og_description":"Python Operator Precedence - Explore precedence table in Python, expressions in Python, PEMDAS\u00a0rule, Short-Circuiting in Python.","og_url":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2019-12-26T04:42:53+00:00","article_modified_time":"2024-08-22T14:54:19+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/Python-operator-precedence-1.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Python Operator Precedence &#8211; Learn how to perform operations in Python","datePublished":"2019-12-26T04:42:53+00:00","dateModified":"2024-08-22T14:54:19+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/"},"wordCount":994,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/Python-operator-precedence-1.jpg","keywords":["associativity of operators in python","operator precedence in python","python operator precedence","python operator precedence table","python rules","What are expressions in python"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/","url":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/","name":"Python Operator Precedence - Learn how to perform operations in Python - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/Python-operator-precedence-1.jpg","datePublished":"2019-12-26T04:42:53+00:00","dateModified":"2024-08-22T14:54:19+00:00","description":"Python Operator Precedence - Explore precedence table in Python, expressions in Python, PEMDAS\u00a0rule, Short-Circuiting in Python.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/Python-operator-precedence-1.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/Python-operator-precedence-1.jpg","width":802,"height":420,"caption":"Operator precedence in python"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/python-operator-precedence\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Python Operator Precedence &#8211; Learn how to perform operations in Python"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/74599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=74599"}],"version-history":[{"count":2,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/74599\/revisions"}],"predecessor-version":[{"id":447701,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/74599\/revisions\/447701"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/74720"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=74599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=74599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=74599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}