{"id":2638,"date":"2026-10-19T10:04:55","date_gmt":"2026-10-19T10:04:55","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=2638"},"modified":"2026-10-20T05:42:55","modified_gmt":"2026-10-20T05:42:55","slug":"python-operators-tutorial","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/","title":{"rendered":"Python Operators"},"content":{"rendered":"<h1><strong><b>Python Operators Tutorial With Examples<\/b><\/strong><\/h1>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Every program you write does the same few things with data. It adds numbers, compares two values, checks whether an item is in a list, or decides whether two conditions are both true. Each of these small actions is done by an operator, a symbol such as the plus sign, the equals sign or a word such as <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">and<\/code>.<\/p>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">An operator tells Python what to do with the values next to it. Those values are called operands. In the expression <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">20 + 3<\/code>, the plus sign is the operator, and 20 and 3 are the operands. The whole thing is called an expression, and Python works out its value. You will use operators in the first program you write and in the ten thousandth, so it pays to learn them properly once.<\/p>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">In this tutorial, we go through all seven groups of Python operators: arithmetic, assignment, comparison, logical, identity, membership and bitwise. Every example uses the same two variables, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x<\/code> as 20 and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">y<\/code> as 3, and shows the real output from Python 3.13. We then cover operator precedence, which decides what runs first, and the mistakes beginners make most often, such as comparing floats with the equals operator and confusing <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">is<\/code> with <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">==<\/code>. We finish with a quick reference and the complete script.<\/p>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Types of Operators in Python<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Python groups its operators by the job they do. Here are the seven groups, with what each one answers.<\/p>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 760px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">The seven groups of Python operators<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 170px;\" scope=\"col\">Group<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">What it does<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Examples<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Arithmetic<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Does maths on numbers<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">+ &#8211; * \/ % ** \/\/<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Assignment<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Stores a value in a variable<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">= += -= *= and more<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Comparison<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Compares two values, gives True or False<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">== != &gt; &lt; &gt;= &lt;=<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Logical<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Combines conditions<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">and or not<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Identity<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Checks if two names point to the same object<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">is is not<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Membership<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Checks if a value is inside a collection<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">in not in<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise<\/th>\r\n<td style=\"padding: 12px 16px;\">Works on the binary bits of whole numbers<\/td>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&amp; | ^ ~ &lt;&lt; &gt;&gt;<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">For every example below, we start with these two variables:<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">x = 20\r\ny = 3<\/pre>\r\n<\/div>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Arithmetic Operators in Python<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Arithmetic operators do the maths you learned at school. Python has seven of them.<\/p>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 720px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Arithmetic operators with x as 20 and y as 3<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 170px;\" scope=\"col\">Name<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Symbol<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Example<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Result<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Addition<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">+<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x + y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">23<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Subtraction<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&#8211;<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &#8211; y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">17<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Multiplication<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">*<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x * y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">60<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Division<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">\/<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x \/ y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">6.666666666666667<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Modulus<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">%<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x % y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">2 (the remainder)<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Exponent<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">**<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x ** y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">8000 (20 to the power 3)<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Floor division<\/th>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">\/\/<\/td>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x \/\/ y<\/td>\r\n<td style=\"padding: 12px 16px;\">6 (the whole number part)<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">x = 20\r\ny = 3\r\nprint(x + y, x - y, x * y)\r\nprint(x \/ y)\r\nprint(round(x \/ y, 2))\r\nprint(x % y, x ** y, x \/\/ y)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">23 17 60\r\n6.666666666666667\r\n6.67\r\n2 8000 6<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Two points trip up beginners. First, the division operator always returns a float, even when the numbers divide evenly, so 8 divided by 2 gives 4.0 and not 4. Second, Python does not round on its own, so the division above prints 6.666666666666667. Use the <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">round<\/code> function when you want fewer decimals.<\/p>\r\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Floor Division and Modulus With Negative Numbers<\/h3>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Floor division rounds down toward minus infinity, not toward zero. That surprises people when a number is negative.<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(-20 \/\/ 3, -20 % 3)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">-7 1<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The result of minus 20 floor divided by 3 is minus 7, not minus 6, and the remainder is 1. Python keeps the rule that <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">(a \/\/ b) * b + (a % b)<\/code> always gives back <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">a<\/code>.<\/p>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Assignment Operators in Python<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The plain equals sign stores a value in a variable. The other assignment operators are shortcuts. They do an operation and store the result back in the same variable, so <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x += 5<\/code> means the same as <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x = x + 5<\/code>. In the table, every row starts again with <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x<\/code> as 20.<\/p>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 860px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Assignment operators<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 230px;\" scope=\"col\">Name<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Symbol<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Example<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Same as<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Result<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = 20<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = 20<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">20<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Add and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">+=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x += 5<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x + 5<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">25<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Subtract and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">-=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x -= 5<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x &#8211; 5<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">15<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Multiply and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">*=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x *= 2<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x * 2<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">40<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Divide and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">\/=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x \/= 2<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x \/ 2<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">10.0<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Modulus and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">%=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x %= 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x % 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">2<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Floor divide and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">\/\/=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x \/\/= 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x \/\/ 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">6<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Exponent and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">**=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x **= 2<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x ** 2<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">400<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise AND and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&amp;=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &amp;= 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x &amp; 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">0<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise OR and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">|=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x |= 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x | 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">23<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise XOR and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">^=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x ^= 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x ^ 3<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">23<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Right shift and assign<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&gt;&gt;=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &gt;&gt;= 2<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x &gt;&gt; 2<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">5<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Left shift and assign<\/th>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&lt;&lt;=<\/td>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &lt;&lt;= 3<\/td>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x = x &lt;&lt; 3<\/td>\r\n<td style=\"padding: 12px 16px;\">160<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">x = 20\r\nx += 5\r\nprint(x)\r\nx \/= 5\r\nprint(x)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">25\r\n5.0<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The bitwise rows give whole numbers, because those operators work on integers. The last six rows make sense after you read the bitwise section further down.<\/p>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Comparison Operators in Python<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Comparison operators compare two values and return True or False. You will use them in every <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">if<\/code> statement and every loop condition.<\/p>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 720px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Comparison operators with x as 20 and y as 3<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 240px;\" scope=\"col\">Name<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Symbol<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Example<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Result<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Equal to<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">==<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x == y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">False<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Not equal to<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">!=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x != y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Greater than<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&gt;<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &gt; y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Less than<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&lt;<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &lt; y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">False<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Greater than or equal to<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&gt;=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &gt;= y<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Less than or equal to<\/th>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&lt;=<\/td>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &lt;= y<\/td>\r\n<td style=\"padding: 12px 16px;\">False<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">x = 20\r\ny = 3\r\nprint(x == y, x != y, x &gt; y, x &lt; y, x &gt;= y, x &lt;= y)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">False True True False True False<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">One equals sign stores a value, and two equals signs compare. Mixing them up is a very common first error.<\/p>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Logical Operators in Python<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Logical operators combine conditions. The word <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">and<\/code> gives True only when both sides are true. The word <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">or<\/code> gives True when at least one side is true. The word <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">not<\/code> flips the answer.<\/p>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 700px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Logical operators<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 140px;\" scope=\"col\">Operator<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Meaning<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Example<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\" scope=\"row\">and<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True if both conditions are true<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &gt; 10 and y &lt; 5<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\" scope=\"row\">or<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True if at least one condition is true<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">x &gt; 10 or y &gt; 5<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\" scope=\"row\">not<\/th>\r\n<td style=\"padding: 12px 16px;\">Reverses the result<\/td>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">not x &gt; 10<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">x = 20\r\ny = 3\r\nprint(x &gt; 10 and y &lt; 5, x &gt; 10 or y &gt; 5, not x &gt; 10)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">True True False<\/pre>\r\n<\/div>\r\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">and and or Return an Operand, Not Just True or False<\/h3>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">With conditions, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">and<\/code> and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">or<\/code> give True or False. With plain values, they return one of the two values themselves. Python treats 0, empty text, an empty list and None as false, and everything else as true.<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">x = 20\r\nprint(x and 0, x or 0, 0 or \"default\", 0 and 5)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">0 20 default 0<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Here, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x and 0<\/code> gives 0 because <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x<\/code> is true, so Python moves to the second value and returns it. And <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x or 0<\/code> gives 20, because <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">x<\/code> is already true and Python stops there. Python also stops early when the answer is known. That is called short circuit evaluation, and it lets you write safe checks such as <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">len(items) &gt; 0 and items[0] == 5<\/code>, where the second part never runs if the list is empty.<\/p>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Identity Operators in Python<\/h2>\r\n<p style=\"margin: 0 0 16px;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5571 size-full\" style=\"display: block; max-width: 100%; height: auto; margin: 0 auto; border: 0;\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png\" alt=\"operator in python\" width=\"900\" height=\"500\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png 900w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design-300x167.png 300w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design-768x427.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Identity operators check whether two names point to the same object in memory. That is different from asking whether two values look equal.<\/p>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 700px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Identity operators<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 140px;\" scope=\"col\">Operator<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Meaning<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Example<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\" scope=\"row\">is<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True if both names point to the same object<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">p is q<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\" scope=\"row\">is not<\/th>\r\n<td style=\"padding: 12px 16px;\">True if they point to different objects<\/td>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">p is not r<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">p = [1, 2, 3]\r\nq = p\r\nr = [1, 2, 3]\r\nprint(p is q, p is r, p == r, p is not r)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">True False True True<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The names <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">p<\/code> and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">q<\/code> point to the same list, so <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">p is q<\/code> is True. The name <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">r<\/code> is a separate list that holds the same values, so <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">p == r<\/code> is True, but <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">p is r<\/code> is False. In short, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">==<\/code> asks whether the values are equal, and <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">is<\/code> asks whether it is the very same object.<\/p>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The most useful everyday use of <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">is<\/code> is the check against None:<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">v = None\r\nprint(v is None)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">True<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Avoid using <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">is<\/code> to compare numbers or text. Python sometimes reuses small objects, so the answer can change from one case to another. Use <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">==<\/code> for values.<\/p>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Membership Operators in Python<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Membership operators check whether a value is present inside a collection such as a string, list, tuple, set or dictionary.<\/p>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 700px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Membership operators<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 140px;\" scope=\"col\">Operator<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Meaning<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Example<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\" scope=\"row\">in<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True if the value is found in the collection<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">3 in [1, 2, 3]<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\" scope=\"row\">not in<\/th>\r\n<td style=\"padding: 12px 16px;\">True if the value is not found<\/td>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&#8220;z&#8221; not in &#8220;apple&#8221;<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(\"a\" in \"apple\", \"z\" not in \"apple\")\r\nprint(3 in [1, 2, 3], 5 in (1, 2), \"k\" in {\"k\": 1}, 1 in {\"k\": 1})<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">True True\r\nTrue False True False<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">For a dictionary, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">in<\/code> checks the keys and not the values, which is why 1 in the dictionary gives False. Using <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">in<\/code> with a plain number on the right raises an error, because a number is not a collection:<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">try:\r\n    print(3 in 20)\r\nexcept TypeError as error:\r\n    print(\"TypeError:\", error)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">TypeError: argument of type 'int' is not iterable<\/pre>\r\n<\/div>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Bitwise Operators in Python<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Bitwise operators work on the individual bits, the ones and zeros, of whole numbers. You will not need them every day, but they appear in permissions, flags, networking, hardware code and interview questions. Here is a worked example using 12 and 10.<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">a = 12\r\nb = 10\r\nprint(format(a, \"04b\"), format(b, \"04b\"))<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">1100 1010<\/pre>\r\n<\/div>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 800px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Bitwise operators with a as 12 and b as 10<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 170px;\" scope=\"col\">Name<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Symbol<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">What it does<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Example and result<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise AND<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&amp;<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">1 only where both bits are 1<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">12 &amp; 10 gives 8 (1000)<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise OR<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">|<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">1 where at least one bit is 1<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">12 | 10 gives 14 (1110)<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise XOR<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">^<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">1 where the bits differ<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">12 ^ 10 gives 6 (0110)<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise NOT<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">~<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Flips every bit<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">~12 gives minus 13<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Left shift<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&lt;&lt;<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Moves bits left, fills with zeros<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">12 &lt;&lt; 2 gives 48<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Right shift<\/th>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&gt;&gt;<\/td>\r\n<td style=\"padding: 12px 16px;\">Moves bits right<\/td>\r\n<td style=\"padding: 12px 16px;\">12 &gt;&gt; 2 gives 3<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">a = 12\r\nb = 10\r\nprint(a &amp; b, a | b, a ^ b)\r\nprint(~a)\r\nprint(a &lt;&lt; 2, a &gt;&gt; 2)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">8 14 6\r\n-13\r\n48 3<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The tilde operator is bitwise NOT, not NOR. For whole numbers, <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">~a<\/code> equals minus <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">a<\/code> minus 1, which is why <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">~12<\/code> gives minus 13. A left shift by 2 multiplies by 4, and a right shift by 2 divides by 4 and drops the remainder.<\/p>\r\n<div style=\"position: relative; width: 100%; max-width: 800px; margin: 20px auto; padding-bottom: min(56.25%,450px); height: 0; overflow: hidden; border: 1px solid #d9e0ea; border-radius: 8px;\"><iframe style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;\" title=\"Python operators video\" src=\"https:\/\/www.youtube.com\/embed\/j-UnQNn07LA\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Operator Precedence in Python<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">When an expression has more than one operator, Python does not just read left to right. It follows precedence rules, the same idea as BODMAS in maths. Here they are, from highest to lowest.<\/p>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 760px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Operator precedence from highest to lowest<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 100px;\" scope=\"col\">Order<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Operators<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Note<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">1<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">( ) parentheses<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Always runs first<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">2<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">**<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Right to left<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">3<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">+x -x ~x (unary)<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Sign and bitwise NOT<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">4<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">* \/ \/\/ %<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Left to right<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">5<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">+ &#8211;<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Left to right<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">6<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&lt;&lt; &gt;&gt;<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Shifts<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">7<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&amp; then ^ then |<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Bitwise, in this order<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">8<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">== != &gt; &lt; &gt;= &lt;= is is not in not in<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Comparisons<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">9<\/th>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">not then and then or<\/td>\r\n<td style=\"padding: 12px 16px;\">Logical, in this order<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(2 + 3 * 4, (2 + 3) * 4)\r\nprint(2 ** 3 ** 2, -3 ** 2, (-3) ** 2)\r\nprint(10 - 2 - 3, 100 \/ 10 \/ 5)\r\nprint(True or False and False)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">14 20\r\n512 -9 9\r\n5 2.0\r\nTrue<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Look at the second line. The exponent runs right to left, so <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">2 ** 3 ** 2<\/code> is <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">2 ** 9<\/code>, which is 512. And <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">-3 ** 2<\/code> gives minus 9, because the exponent runs before the minus sign. When in doubt, use brackets. They cost nothing and make the code easy to read.<\/p>\r\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Chained Comparisons<\/h3>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Python lets you chain comparisons the way you write them in maths. This is cleaner than joining two checks with <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">and<\/code>.<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(1 &lt; 2 &lt; 3, 1 &lt; 3 &lt; 2)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">True False<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The first chain asks whether 2 is greater than 1 and also less than 3. Use it for range checks, such as <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">0 &lt;= marks &lt;= 100<\/code>.<\/p>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Common Mistakes With Python Operators<\/h2>\r\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Comparing Floats With ==<\/h3>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Decimal numbers are stored in binary, so some cannot be held exactly. This gives a result that surprises everyone once.<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(0.1 + 0.2 == 0.3, round(0.1 + 0.2, 2) == 0.3)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">False True<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Round the numbers first, or use the <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">isclose<\/code> function from the <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">math<\/code> module.<\/p>\r\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Mixing Up Division and Floor Division<\/h3>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">print(7 \/ 2, 7 \/\/ 2, type(7 \/ 2).__name__, type(8 \/ 2).__name__)<\/pre>\r\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">3.5 3 float float<\/pre>\r\n<\/div>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Use the division operator for an exact answer, and floor division when you need a whole number, such as the number of full pages or full boxes.<\/p>\r\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Using is Instead of ==<\/h3>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Use <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">==<\/code> to compare values. Keep <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">is<\/code> for None and for cases where you truly want to know whether two names share one object.<\/p>\r\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Using = Instead of ==<\/h3>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A single equals sign stores a value. Writing <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">if x = 20<\/code> gives a SyntaxError. Write <code style=\"font-family: 'Courier New',Courier,monospace; font-size: 15px; background: #eef2f7; padding: 2px 6px; border-radius: 4px;\">if x == 20<\/code>.<\/p>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Quick Reference<\/h2>\r\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\r\n<table style=\"width: 100%; min-width: 820px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Python operators quick reference<\/caption>\r\n<thead>\r\n<tr>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 150px;\" scope=\"col\">Group<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Operators<\/th>\r\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Returns<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Arithmetic<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">+ &#8211; * \/ % ** \/\/<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">A number<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Assignment<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">= += -= *= \/= %= \/\/= **= &amp;= |= ^= &gt;&gt;= &lt;&lt;=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Nothing, it stores a value<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Comparison<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">== != &gt; &lt; &gt;= &lt;=<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True or False<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Logical<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">and or not<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">An operand, or True or False<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Identity<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">is is not<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True or False<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Membership<\/th>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">in not in<\/td>\r\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">True or False<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Bitwise<\/th>\r\n<td style=\"padding: 12px 16px; font-family: 'Courier New',Courier,monospace; font-size: 15px; white-space: nowrap;\">&amp; | ^ ~ &lt;&lt; &gt;&gt;<\/td>\r\n<td style=\"padding: 12px 16px;\">A whole number<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Complete Script to Run Yourself<\/h2>\r\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Here is the script that produces every output on this page. Copy it into a file, run it with Python 3, and compare the results line by line.<\/p>\r\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\r\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\r\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">x = 20\r\ny = 3\r\n\r\n# Arithmetic\r\nprint(x + y, x - y, x * y)\r\nprint(x \/ y)\r\nprint(round(x \/ y, 2))\r\nprint(x % y, x ** y, x \/\/ y)\r\nprint(-20 \/\/ 3, -20 % 3)\r\n\r\n# Comparison\r\nprint(x == y, x != y, x &gt; y, x &lt; y, x &gt;= y, x &lt;= y)\r\n\r\n# Logical\r\nprint(x &gt; 10 and y &lt; 5, x &gt; 10 or y &gt; 5, not x &gt; 10)\r\nprint(x and 0, x or 0, 0 or \"default\", 0 and 5)\r\n\r\n# Assignment\r\nn = 20\r\nn += 5\r\nprint(n)\r\nn -= 3\r\nprint(n)\r\nn *= 2\r\nprint(n)\r\nn \/= 4\r\nprint(n)\r\nn = 20\r\nn %= 3\r\nprint(n)\r\nn = 20\r\nn \/\/= 3\r\nprint(n)\r\nn = 20\r\nn **= 2\r\nprint(n)\r\nn = 20\r\nn &amp;= 3\r\nprint(n)\r\nn = 20\r\nn |= 3\r\nprint(n)\r\nn = 20\r\nn ^= 3\r\nprint(n)\r\nn = 20\r\nn &gt;&gt;= 2\r\nprint(n)\r\nn = 20\r\nn &lt;&lt;= 3\r\nprint(n)\r\n\r\n# Bitwise\r\na = 12\r\nb = 10\r\nprint(format(a, \"04b\"), format(b, \"04b\"))\r\nprint(a &amp; b, format(a &amp; b, \"04b\"))\r\nprint(a | b, format(a | b, \"04b\"))\r\nprint(a ^ b, format(a ^ b, \"04b\"))\r\nprint(~a)\r\nprint(a &lt;&lt; 2, a &gt;&gt; 2)\r\n\r\n# Identity\r\np = [1, 2, 3]\r\nq = p\r\nr = [1, 2, 3]\r\nprint(p is q, p is r, p == r, p is not r)\r\nprint(id(p) == id(q))\r\nprint(None is None)\r\nv = None\r\nprint(v is None)\r\n\r\n# Membership\r\nprint(\"a\" in \"apple\", \"z\" not in \"apple\")\r\nprint(3 in [1, 2, 3], 5 in (1, 2), \"k\" in {\"k\": 1}, 1 in {\"k\": 1})\r\ntry:\r\n    print(3 in 20)\r\nexcept TypeError as e:\r\n    print(\"TypeError:\", e)\r\n\r\n# Precedence\r\nprint(2 + 3 * 4, (2 + 3) * 4, 2 ** 3 ** 2, -3 ** 2, (-3) ** 2)\r\nprint(10 - 2 - 3, 100 \/ 10 \/ 5)\r\nprint(1 &lt; 2 &lt; 3, 1 &lt; 3 &lt; 2)\r\nprint(True or False and False)\r\nprint(not True == False)\r\n\r\n# Pitfalls\r\nprint(0.1 + 0.2 == 0.3, round(0.1 + 0.2, 2) == 0.3)\r\nprint(7 \/ 2, 7 \/\/ 2, type(7 \/ 2).__name__, type(8 \/ 2).__name__)<\/pre>\r\n<\/div>\r\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/j-UnQNn07LA\" width=\"850\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><\/p>\r\n<p>Operators are small, but they sit inside almost every line you will write. Learn the seven groups, remember that and and or return operands, that the division operator gives a float, and that is is not the same as ==, and you will avoid most beginner bugs. Run the script above, change the numbers, and watch what happens. Then move on to Python conditions and loops, where these operators do the real work.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Python Operators Tutorial With Examples Every program you write does the same few things with data. It adds numbers, compares two values, checks whether an item is in a list, or decides whether two conditions are both true. Each of these small actions is done by an operator, a symbol such as the plus sign, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,1671],"tags":[540,541,546,542,498,351,499],"class_list":["post-2638","post","type-post","status-publish","format-standard","hentry","category-python","category-python-data-types","tag-online-course-to-learn-python","tag-online-python-course-for-beginners","tag-online-python-programming-course","tag-online-python-training-course","tag-operators-in-python-language","tag-python-operators-tutorial","tag-types-of-operators-in-python-programming-language"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Operators Tutorial for Beginners with Examples | Prwatech<\/title>\n<meta name=\"description\" content=\"Learn all 7 types of Python operators: arithmetic, assignment, comparison, logical, identity, membership and bitwise, with tested output and precedence.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Operators Tutorial for Beginners with Examples | Prwatech\" \/>\n<meta property=\"og:description\" content=\"Learn all 7 types of Python operators: arithmetic, assignment, comparison, logical, identity, membership and bitwise, with tested output and precedence.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-19T10:04:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-20T05:42:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/\",\"url\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/\",\"name\":\"Python Operators Tutorial for Beginners with Examples | Prwatech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png\",\"datePublished\":\"2026-10-19T10:04:55+00:00\",\"dateModified\":\"2026-10-20T05:42:55+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Learn all 7 types of Python operators: arithmetic, assignment, comparison, logical, identity, membership and bitwise, with tested output and precedence.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png\",\"width\":900,\"height\":500},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Operators\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Operators Tutorial for Beginners with Examples | Prwatech","description":"Learn all 7 types of Python operators: arithmetic, assignment, comparison, logical, identity, membership and bitwise, with tested output and precedence.","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:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Python Operators Tutorial for Beginners with Examples | Prwatech","og_description":"Learn all 7 types of Python operators: arithmetic, assignment, comparison, logical, identity, membership and bitwise, with tested output and precedence.","og_url":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2026-10-19T10:04:55+00:00","article_modified_time":"2026-10-20T05:42:55+00:00","og_image":[{"width":900,"height":500,"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png","type":"image\/png"}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/","url":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/","name":"Python Operators Tutorial for Beginners with Examples | Prwatech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png","datePublished":"2026-10-19T10:04:55+00:00","dateModified":"2026-10-20T05:42:55+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Learn all 7 types of Python operators: arithmetic, assignment, comparison, logical, identity, membership and bitwise, with tested output and precedence.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/Untitled-design.png","width":900,"height":500},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-operators-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Operators"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=2638"}],"version-history":[{"count":15,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2638\/revisions"}],"predecessor-version":[{"id":12043,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2638\/revisions\/12043"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=2638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=2638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=2638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}