You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _sources/chap01.ipynb
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -223,9 +223,9 @@
223
223
"source": [
224
224
"Notice that the result of the division is `42.0` rather than `42`. That's because there are two types of numbers in Python: \n",
225
225
"\n",
226
-
"* **integers**, which represent whole numbers, and \n",
226
+
"* **integers**, which represent numbers with no fractional or decimal part, and \n",
227
227
"\n",
228
-
"* **floating-point numbers**, which represent numbers with a decimal point.\n",
228
+
"* **floating-point numbers**, which represent integers and numbers with a decimal point.\n",
229
229
"\n",
230
230
"If you add, subtract, or multiply two integers, the result is an integer.\n",
231
231
"But if you divide two integers, the result is a floating-point number.\n",
@@ -464,7 +464,7 @@
464
464
"## Arithmetic functions\n",
465
465
"\n",
466
466
"In addition to the arithmetic operators, Python provides a few **functions** that work with numbers.\n",
467
-
"For example, the `round` function takes a floating-point number and rounds it off to the nearest whole number."
467
+
"For example, the `round` function takes a floating-point number and rounds it off to the nearest integer."
468
468
]
469
469
},
470
470
{
@@ -845,7 +845,7 @@
845
845
"source": [
846
846
"The other arithmetic operators don't work with strings.\n",
847
847
"\n",
848
-
"Python provides a function called `len` that computes the length of a string.`"
848
+
"Python provides a function called `len` that computes the length of a string."
849
849
]
850
850
},
851
851
{
@@ -1388,10 +1388,10 @@
1388
1388
"A symbol, like `+` and `*`, that denotes an arithmetic operation like addition or multiplication.\n",
1389
1389
"\n",
1390
1390
"**integer:**\n",
1391
-
"A type that represents whole numbers.\n",
1391
+
"A type that represents numbers with no fractional or decimal part.\n",
1392
1392
"\n",
1393
1393
"**floating-point:**\n",
1394
-
"A type that represents numbers with fractional parts.\n",
1394
+
"A type that represents integers and numbers with decimal parts.\n",
1395
1395
"\n",
1396
1396
"**integer division:**\n",
1397
1397
"An operator, `//`, that divides two numbers and rounds down to an integer.\n",
@@ -1501,7 +1501,7 @@
1501
1501
"\n",
1502
1502
"* I also mentioned the order of operations. For more details, ask \"What is the order of operations in Python?\"\n",
1503
1503
"\n",
1504
-
"* The `round` function, which we used to round a floating-point number to the nearest whole number, can take a second argument. Try asking \"What are the arguments of the round function?\" or \"How do I round pi off to three decimal places?\"\n",
1504
+
"* The `round` function, which we used to round a floating-point number to the nearest integer, can take a second argument. Try asking \"What are the arguments of the round function?\" or \"How do I round pi off to three decimal places?\"\n",
1505
1505
"\n",
1506
1506
"* There's one more arithmetic operator I didn't mention; try asking \"What is the modulus operator in Python?\""
<p>Notice that the result of the division is <codeclass="docutils literal notranslate"><spanclass="pre">42.0</span></code> rather than <codeclass="docutils literal notranslate"><spanclass="pre">42</span></code>. That’s because there are two types of numbers in Python:</p>
466
466
<ulclass="simple">
467
-
<li><p><strong>integers</strong>, which represent whole numbers, and</p></li>
468
-
<li><p><strong>floating-point numbers</strong>, which represent numbers with a decimal point.</p></li>
467
+
<li><p><strong>integers</strong>, which represent numbers with no fractional or decimal part, and</p></li>
468
+
<li><p><strong>floating-point numbers</strong>, which represent integers and numbers with a decimal point.</p></li>
469
469
</ul>
470
470
<p>If you add, subtract, or multiply two integers, the result is an integer.
471
471
But if you divide two integers, the result is a floating-point number.
<h2><spanclass="section-number">1.3. </span>Arithmetic functions<aclass="headerlink" href="#arithmetic-functions" title="Link to this heading">#</a></h2>
581
581
<p>In addition to the arithmetic operators, Python provides a few <strong>functions</strong> that work with numbers.
582
-
For example, the <codeclass="docutils literal notranslate"><spanclass="pre">round</span></code> function takes a floating-point number and rounds it off to the nearest whole number.</p>
582
+
For example, the <codeclass="docutils literal notranslate"><spanclass="pre">round</span></code> function takes a floating-point number and rounds it off to the nearest integer.</p>
<p>The other arithmetic operators don’t work with strings.</p>
755
-
<p>Python provides a function called <codeclass="docutils literal notranslate"><spanclass="pre">len</span></code> that computes the length of a string.`</p>
755
+
<p>Python provides a function called <codeclass="docutils literal notranslate"><spanclass="pre">len</span></code> that computes the length of a string.</p>
A symbol, like <codeclass="docutils literal notranslate"><spanclass="pre">+</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">*</span></code>, that denotes an arithmetic operation like addition or multiplication.</p>
1001
1001
<p><strong>integer:</strong>
1002
-
A type that represents whole numbers.</p>
1002
+
A type that represents numbers with no fractional or decimal part.</p>
1003
1003
<p><strong>floating-point:</strong>
1004
-
A type that represents numbers with fractional parts.</p>
1004
+
A type that represents integers and numbers with decimal parts.</p>
1005
1005
<p><strong>integer division:</strong>
1006
1006
An operator, <codeclass="docutils literal notranslate"><spanclass="pre">//</span></code>, that divides two numbers and rounds down to an integer.</p>
<li><p>Earlier I mentioned bitwise operators but I didn’t explain why the value of <codeclass="docutils literal notranslate"><spanclass="pre">7</span><spanclass="pre">^</span><spanclass="pre">2</span></code> is 5. Try asking “What are the bitwise operators in Python?” or “What is the value of <codeclass="docutils literal notranslate"><spanclass="pre">7</span><spanclass="pre">XOR</span><spanclass="pre">2</span></code>?”</p></li>
1066
1066
<li><p>I also mentioned the order of operations. For more details, ask “What is the order of operations in Python?”</p></li>
1067
-
<li><p>The <codeclass="docutils literal notranslate"><spanclass="pre">round</span></code> function, which we used to round a floating-point number to the nearest whole number, can take a second argument. Try asking “What are the arguments of the round function?” or “How do I round pi off to three decimal places?”</p></li>
1067
+
<li><p>The <codeclass="docutils literal notranslate"><spanclass="pre">round</span></code> function, which we used to round a floating-point number to the nearest integer, can take a second argument. Try asking “What are the arguments of the round function?” or “How do I round pi off to three decimal places?”</p></li>
1068
1068
<li><p>There’s one more arithmetic operator I didn’t mention; try asking “What is the modulus operator in Python?”</p></li>
1069
1069
</ul>
1070
1070
<p>Most virtual assistants know about Python, so they answer questions like this pretty reliably.
0 commit comments