<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Eddie Svirsky</title>
    <description>The latest articles on Forem by Eddie Svirsky (@cryo8822).</description>
    <link>https://forem.com/cryo8822</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F289852%2F866c0556-a86f-4c5e-82f4-e80c376c6b76.png</url>
      <title>Forem: Eddie Svirsky</title>
      <link>https://forem.com/cryo8822</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cryo8822"/>
    <language>en</language>
    <item>
      <title>Python Operators</title>
      <dc:creator>Eddie Svirsky</dc:creator>
      <pubDate>Sat, 21 Mar 2020 17:44:04 +0000</pubDate>
      <link>https://forem.com/cryo8822/python-operators-24pi</link>
      <guid>https://forem.com/cryo8822/python-operators-24pi</guid>
      <description>&lt;p&gt;There are five groups of operators in the Python programming language: arithmetic, comparison, assignment, logical, identity, membership, and bitwise.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arithmetic operators - are used to perform basic mathematical operations&lt;/li&gt;
&lt;li&gt;Comparison operators - are used to compare values, they return a True/False based on the statement&lt;/li&gt;
&lt;li&gt;Assignment operators - are used to perform some operation and assign a value to a variable&lt;/li&gt;
&lt;li&gt;Logical operators - are used to combine conditional statements&lt;/li&gt;
&lt;li&gt;Identity operators - are used to determine if objects are the same&lt;/li&gt;
&lt;li&gt;Membership operators - are used to determine if a value is found in a sequence&lt;/li&gt;
&lt;li&gt;Bitwise operators - are used to perform operations at the bit level&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Arithmetic Operators&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;+&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-addition/"&gt;Addition&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-subtraction/"&gt;Subtraction&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;*&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-multiplication/"&gt;Multiplication&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-division/"&gt;Division&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;//&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-floor-division/"&gt;Floor division&lt;/a&gt; - round down division&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;%&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-modulo/"&gt;Modulo operation&lt;/a&gt; - remainder from division&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;**&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-power-operator/"&gt;Power operation&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;11&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;24&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mf"&gt;2.6666666666666665&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;Order of operation&lt;/h3&gt;

&lt;p&gt;In Python, just like in Math order of arithmetic operations is governed by &lt;strong&gt;PEMDAS &lt;/strong&gt;- Parentheses, Exponent, Multiplication, Division, Addition, Subtraction.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;
&lt;span class="mi"&gt;19&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;
&lt;span class="mi"&gt;40&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Comparison Operators&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;==&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-equal/"&gt;Equal&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;!=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-not-equal/"&gt;Not equal&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-greater-than/"&gt;Greater than&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-less-than/"&gt;Less than&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-greater-than-or-equal/"&gt;Greater than or equal&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-less-than-or-equal/"&gt;Less than or equal&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; 
&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Assignment Operators&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-assignment/"&gt;Assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;+=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-addition-assignment/"&gt;Addition assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-subtraction-assignment/"&gt;Subtraction assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;*=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-multiplication-assignment/"&gt;Multiplication assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-division-assignment/"&gt;Division assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;%=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-modulus-assignment/"&gt;Modulus assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;//=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-floor-division-assignment/"&gt;Floor division assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;**=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-power-assignment/"&gt;Power assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-and-assignment/"&gt;Bitwise AND assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;|=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-or-assignment/"&gt;Bitwise OR assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;^=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-xor-assignment/"&gt;Bitwise XOR assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&amp;gt;=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-shift-right-assignment/"&gt;Bitwise shift right assignment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&amp;lt;=&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-shift-left-assignment/"&gt;Bitwise shift left assignment&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Logical Operators&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;and&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-and/"&gt;And logical operation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;or&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-or/"&gt;Or logical operation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;not&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-not/"&gt;Not logical operation&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Identity Operators&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;is&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-is/"&gt;Is the same object&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;is not&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-is-not/"&gt;Is not the same object&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Membership Operators&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;in&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-in/"&gt;And logical operation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;not in&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-not-in/"&gt;Or logical operation&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Bitwise Operators&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-and/"&gt;Bitwise AND&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;|&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-or/"&gt;Bitwise OR&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;^&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-xor/"&gt;Bitwise XOR&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-shift-right/"&gt;Bitwise shift right&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;: &lt;a href="https://www.queworx.com/python/python-bitwise-shift-left/"&gt;Bitwise shift left&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;11&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; 
&lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="mi"&gt;36&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Combining Operators&lt;/h2&gt;

&lt;p&gt;You can combine the various operators above in various ways, such as:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;  &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>python</category>
    </item>
    <item>
      <title>Windows 10 + Python = VS Code + WSL</title>
      <dc:creator>Eddie Svirsky</dc:creator>
      <pubDate>Wed, 11 Dec 2019 01:54:46 +0000</pubDate>
      <link>https://forem.com/cryo8822/windows-10-python-vs-code-wsl-22ob</link>
      <guid>https://forem.com/cryo8822/windows-10-python-vs-code-wsl-22ob</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---ZlGDijv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/m2_ceykmjmgcdvt9mn0_6vok2r8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---ZlGDijv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/m2_ceykmjmgcdvt9mn0_6vok2r8.png" alt="Microsoft"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Translation of an article originally posted on &lt;a href="https://habr.com/en/post/472202/"&gt;habr.ru&lt;/a&gt;, published by &lt;a href="https://habr.com/en/users/r_clark/"&gt;r_clark&lt;/a&gt;&lt;br&gt;
on October 20, 2019]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microsoft&lt;/strong&gt;… The technological locomotive of our time. It’s no secret that they’re cool, and that they’re absorbing more and more… &lt;del&gt;of everything&lt;/del&gt;. Fortunately, lately they have only been encouraging me with their potential. And after the &lt;a href="https://www.theverge.com/2019/10/3/20896908/microsoft-windows-satya-nadella-importance-apps-services-android"&gt;presentation&lt;/a&gt; by &lt;em&gt;Satya Nadella&lt;/em&gt;, where he told the world that Windows is no longer the main product of the company, as they set their course on the implementation of their APIs… &lt;del&gt;Everywhere&lt;/del&gt;…&lt;/p&gt;

&lt;p&gt;They aren’t skimping for software developers either. C#, Azure, Visual Studio… But right now we’ll talk about Python, since they warmed up a spot for it as well.&lt;/p&gt;
&lt;h2&gt;
  
  
  Briefly about WSL
&lt;/h2&gt;

&lt;p&gt;With a Windows update it became possibly to use &lt;a href="https://docs.microsoft.com/ru-ru/windows/wsl/about"&gt;WSL&lt;/a&gt; (Windows Subsystem for Linux). Not too long ago &lt;a href="https://docs.microsoft.com/ru-ru/windows/wsl/wsl2-about"&gt;WSL2&lt;/a&gt; appeared with VERY cool improvements. WSL2 uses the latest and newest virtualization technology to launch a Linux kernel inside a simplified service virtual machine. That means that attributes like isolation and slow downs are now absent.&lt;/p&gt;
&lt;h2&gt;
  
  
  Linux or Linux
&lt;/h2&gt;

&lt;p&gt;Sooner or later, developers decide on what environment to develop in, and that is a very important moment. A fairly important role is played by the operating system, where the code is run. Since the issue is not just about the compiler and interpreter, but also the services that work in a close and friendly circle. And the OS answers for the correctness of the work of these fighting units. The conversation is going to be Windows and Linux. And it’s not going to be about IT’S better, or IT’S worse, since the choice of editor or system is no more than a matter of taste these days. ALL of them these days provide a mass of tools for implementing something. The reason that I prefer Linux is flexibility. Unfortunately, not all additions to Python work on the brainchild of Microsoft. For example, celery/redis, git, work with local web servers, docker…. I think those who worked with at least those technologies met with “some difficulties”. So I think that for any Python programmer, working with Linux (MacOS) is necessary, to put it mildly…&lt;/p&gt;
&lt;h2&gt;
  
  
  Beginning of Work
&lt;/h2&gt;

&lt;p&gt;And so, you set a flag in Windows components&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aEvnCXpA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/yul909wkrw-8aex1vw4wcf7smxq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aEvnCXpA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/yul909wkrw-8aex1vw4wcf7smxq.png" alt="Windows subsystem for linux"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and downloaded your favorite distribution from the official store.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cZr0Wvgd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/ykzuddsdwxi0eepyuycn1alsmke-1024x326.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cZr0Wvgd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/ykzuddsdwxi0eepyuycn1alsmke-1024x326.png" alt="Ubuntu image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After some simple user creation manipulations, you get access to the Linux terminal. Nothing unusual, if you don’t take into account, that the file system of both operating systems isn’t isolated from one another, making it possible to manipulate the Windows file system from inside Linux. All logical partitions are available at the mount point.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/mnt/c/Program Files/&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Development
&lt;/h2&gt;

&lt;p&gt;Now we proceed directly to the development. When choosing an editor, I would stay with &lt;strong&gt;Visual Studio Code&lt;/strong&gt;. It includes a lot of tools, including a debugger, which makes it a full-fledged IDE. The creation of a virtual environment on different systems is different. For example, after a applying the command&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python -m venv venv&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;on windows it creates a .bat activator and a python.exe file, while Linux copies the Python binary system. VS Code is fairly flexibly set up with the help of extensions.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Ctrl+Shift+X&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;allows you to quickly jump to add-ons. It necessary to enter WSL into search and download the first extension from the list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n-nGgd-6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/tsre1mb4j37fhgod5lf0eqaxvgu-1024x271.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n-nGgd-6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/tsre1mb4j37fhgod5lf0eqaxvgu-1024x271.png" alt="Remote WSL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For convenient development it’s worth adding Python, Git History, Django… And then whatever your heart desires.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z2O8bTQS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/xvg7phvowlbcdrz2nqu_zjixmsq-1024x213.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z2O8bTQS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/xvg7phvowlbcdrz2nqu_zjixmsq-1024x213.png" alt="Python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--03sPDL8E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/wvu6l-iztklhv_bstg_fumqqdjy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--03sPDL8E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/wvu6l-iztklhv_bstg_fumqqdjy.png" alt="Python Preview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ojOByYk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/sd4i-n4pt1iky9a12nrksqjrnuu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ojOByYk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/sd4i-n4pt1iky9a12nrksqjrnuu.png" alt="Git History"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;After that&lt;/strong&gt;, boldly restart the editor, after which you can open your project&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;File -&amp;gt; Open Folder&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;After loading, pay attention to the lower left corner of the screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oaiZ0CRs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/7eev4rxa14extkiasc5w3tkegqc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oaiZ0CRs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/7eev4rxa14extkiasc5w3tkegqc.png" alt="lower corner WSL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will allow you to re-open the folder using WSL&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u1_QI1bx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/w5bq95tlxi5r86m5fhzg978ln3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u1_QI1bx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/w5bq95tlxi5r86m5fhzg978ln3w.png" alt="Reopen folder in WSL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The difference being&lt;/em&gt;, that VS Code in this case switches to the Linux kernel, which happens to be the bottom layer of the Windows kernel. This will allow you to use the desired interpreter, as well as the terminal directly from the editor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PDXO-Z9---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/zggiiyiwd36jvqsov6zlc2ziggk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PDXO-Z9---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/zggiiyiwd36jvqsov6zlc2ziggk.png" alt="Select Interpreter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ynkFllNL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/hcuon9e78wapx0yfk5a2-si3dvc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ynkFllNL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/hcuon9e78wapx0yfk5a2-si3dvc.png" alt="Select Python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the same way, it’s possible to use the Windows Terminal. This will greatly increase the effectiveness of your work, since WSL is also integrated into it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H0WkZj0Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/6y_h5objrotduxx-owp6vjatimi-1024x278.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H0WkZj0Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/6y_h5objrotduxx-owp6vjatimi-1024x278.png" alt="Windows Terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JDPGWvyT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/h9pfkgdjayed2sjyb2csb4cmvdk-1024x117.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JDPGWvyT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.queworx.com/wp-content/uploads/2019/12/h9pfkgdjayed2sjyb2csb4cmvdk-1024x117.png" alt="cmd"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All in all, this ensures comfortable work in Windows with the capabilities of Linux. And also the predominant factor being that, the work environment has access to the main system, but is isolated from it by the kernel and the base file system.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Other Articles&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.queworx.com/2019/12/13/redux-not-needed-replacing-with-usecontext-and-usereducer-in-react/"&gt;Redux – Not needed! Replacing with useContext and useReducer in React?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.queworx.com/2019/12/08/react-admin-and-django-rest-framework/"&gt;React-admin and Django Rest Framework&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>wsl</category>
      <category>linux</category>
      <category>python</category>
      <category>windows</category>
    </item>
  </channel>
</rss>
