mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
typo [thanks G.G.]
This commit is contained in:
@@ -131,7 +131,7 @@ ZeroDivisionError: int division or modulo by zero</samp></pre>
|
||||
<ol>
|
||||
<li>The <code>/</code> operator performs floating point division. It returns a <code>float</code> even if both the numerator and denominator are <code>int</code>s.
|
||||
<li>The <code>//</code> operator performs a quirky kind of integer division. When the result is positive, you can think of it as truncating (not rounding) to 0 decimal places, but be careful with that.
|
||||
<li>When integer-dividing negative numbers, the <code>//</code> operator rounds “up” to the nearest integer. Mathematically speaking, it’s rounding “down” since <code>−6</code> is less than <code>−5</code>, but it could trip you up if you expecting it to truncate to <code>−5</code>.
|
||||
<li>When integer-dividing negative numbers, the <code>//</code> operator rounds “up” to the nearest integer. Mathematically speaking, it’s rounding “down” since <code>−6</code> is less than <code>−5</code>, but it could trip you up if you were expecting it to truncate to <code>−5</code>.
|
||||
<li>The <code>//</code> operator doesn’t always return an integer. If either the numerator or denominator is a <code>float</code>, it will still round to the nearest integer, but the actual return value will be a <code>float</code>.
|
||||
<li>The <code>**</code> operator means “raised to the power of.” <code>11<sup>2</sup></code> is <code>121</code>.
|
||||
<li>The <code>%</code> operator gives the remainder after performing integer division. <code>11</code> divided by <code>2</code> is <code>5</code> with a remainder of <code>1</code>, so the result here is <code>1</code>.
|
||||
|
||||
Reference in New Issue
Block a user