|
|
@ -587,7 +587,7 @@ to_exclusive = <range>.stop |
|
|
|
<span class="hljs-keyword">from</span> math <span class="hljs-keyword">import</span> log, log10, log2 |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<div><h3 id="statistics">Statistics</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> statistics <span class="hljs-keyword">import</span> mean, median, variance, pvariance, pstdev |
|
|
|
<div><h3 id="statistics">Statistics</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> statistics <span class="hljs-keyword">import</span> mean, median, variance, stdev, pvariance, pstdev |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<div><h3 id="random">Random</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> random <span class="hljs-keyword">import</span> random, randint, choice, shuffle |
|
|
@ -597,18 +597,18 @@ to_exclusive = <range>.stop |
|
|
|
shuffle(<list>) |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<div><h3 id="binhex">Bin, Hex</h3><pre><code class="python language-python hljs"><int> = <span class="hljs-number">0</span>b<bin> <span class="hljs-comment"># Or: 0x<hex></span> |
|
|
|
<int> = int(<span class="hljs-string">'<bin>'</span>, <span class="hljs-number">2</span>) <span class="hljs-comment"># Or: int('<hex>', 16)</span> |
|
|
|
<int> = int(<span class="hljs-string">'0b<bin>'</span>, <span class="hljs-number">0</span>) <span class="hljs-comment"># Or: int('0x<hex>', 0)</span> |
|
|
|
<span class="hljs-string">'0b<bin>'</span> = bin(<int>) <span class="hljs-comment"># Or: hex(<int>)</span> |
|
|
|
<div><h3 id="binhex">Bin, Hex</h3><pre><code class="python language-python hljs"><int> = <span class="hljs-number">0</span>b<bin> <span class="hljs-comment"># Or: 0x<hex></span> |
|
|
|
<int> = int(<span class="hljs-string">'±<bin>'</span>, <span class="hljs-number">2</span>) <span class="hljs-comment"># Or: int('±<hex>', 16)</span> |
|
|
|
<int> = int(<span class="hljs-string">'±0b<bin>'</span>, <span class="hljs-number">0</span>) <span class="hljs-comment"># Or: int('±0x<hex>', 0)</span> |
|
|
|
<span class="hljs-string">'[-]0b<bin>'</span> = bin(<int>) <span class="hljs-comment"># Or: hex(<int>)</span> |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<div><h3 id="bitwiseoperators">Bitwise Operators</h3><pre><code class="python language-python hljs"><int> = <int> & <int> <span class="hljs-comment"># And</span> |
|
|
|
<int> = <int> | <int> <span class="hljs-comment"># Or</span> |
|
|
|
<int> = <int> ^ <int> <span class="hljs-comment"># Xor (0 if both bits equal)</span> |
|
|
|
<int> = <int> << n_bits <span class="hljs-comment"># Shift left</span> |
|
|
|
<int> = <int> >> n_bits <span class="hljs-comment"># Shift right</span> |
|
|
|
<int> = ~<int> <span class="hljs-comment"># Compliment (flips bits)</span> |
|
|
|
<div><h3 id="bitwiseoperators">Bitwise Operators</h3><pre><code class="python language-python hljs"><int> = <int> & <int> <span class="hljs-comment"># And</span> |
|
|
|
<int> = <int> | <int> <span class="hljs-comment"># Or</span> |
|
|
|
<int> = <int> ^ <int> <span class="hljs-comment"># Xor (0 if both bits equal)</span> |
|
|
|
<int> = <int> << n_bits <span class="hljs-comment"># Shift left</span> |
|
|
|
<int> = <int> >> n_bits <span class="hljs-comment"># Shift right</span> |
|
|
|
<int> = ~<int> <span class="hljs-comment"># Compliment (flips bits)</span> |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<div><h2 id="combinatorics"><a href="#combinatorics" name="combinatorics">#</a>Combinatorics</h2><ul> |
|
|
|