|
161 | 161 | "source": [ |
162 | 162 | "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", |
163 | 163 | "\n", |
164 | | - "* **integers**, which represent whole numbers, and \n", |
| 164 | + "* **integers**, which represent numbers with no fractional or decimal part, and \n", |
165 | 165 | "\n", |
166 | | - "* **floating-point numbers**, which represent numbers with a decimal point.\n", |
| 166 | + "* **floating-point numbers**, which represent integers and numbers with a decimal point.\n", |
167 | 167 | "\n", |
168 | 168 | "If you add, subtract, or multiply two integers, the result is an integer.\n", |
169 | 169 | "But if you divide two integers, the result is a floating-point number.\n", |
|
311 | 311 | "## Arithmetic functions\n", |
312 | 312 | "\n", |
313 | 313 | "In addition to the arithmetic operators, Python provides a few **functions** that work with numbers.\n", |
314 | | - "For example, the `round` function takes a floating-point number and rounds it off to the nearest whole number." |
| 314 | + "For example, the `round` function takes a floating-point number and rounds it off to the nearest integer." |
315 | 315 | ] |
316 | 316 | }, |
317 | 317 | { |
|
533 | 533 | "source": [ |
534 | 534 | "The other arithmetic operators don't work with strings.\n", |
535 | 535 | "\n", |
536 | | - "Python provides a function called `len` that computes the length of a string.`" |
| 536 | + "Python provides a function called `len` that computes the length of a string." |
537 | 537 | ] |
538 | 538 | }, |
539 | 539 | { |
|
877 | 877 | "A symbol, like `+` and `*`, that denotes an arithmetic operation like addition or multiplication.\n", |
878 | 878 | "\n", |
879 | 879 | "**integer:**\n", |
880 | | - "A type that represents whole numbers.\n", |
| 880 | + "A type that represents numbers with no fractional or decimal part.\n", |
881 | 881 | "\n", |
882 | 882 | "**floating-point:**\n", |
883 | | - "A type that represents numbers with fractional parts.\n", |
| 883 | + "A type that represents integers and numbers with decimal parts.\n", |
884 | 884 | "\n", |
885 | 885 | "**integer division:**\n", |
886 | 886 | "An operator, `//`, that divides two numbers and rounds down to an integer.\n", |
|
979 | 979 | "\n", |
980 | 980 | "* I also mentioned the order of operations. For more details, ask \"What is the order of operations in Python?\"\n", |
981 | 981 | "\n", |
982 | | - "* 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", |
| 982 | + "* 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", |
983 | 983 | "\n", |
984 | 984 | "* There's one more arithmetic operator I didn't mention; try asking \"What is the modulus operator in Python?\"" |
985 | 985 | ] |
|
1162 | 1162 | "metadata": {}, |
1163 | 1163 | "outputs": [], |
1164 | 1164 | "source": [] |
| 1165 | + }, |
| 1166 | + { |
| 1167 | + "cell_type": "markdown", |
| 1168 | + "id": "a7f4edf8", |
| 1169 | + "metadata": { |
| 1170 | + "tags": [] |
| 1171 | + }, |
| 1172 | + "source": [ |
| 1173 | + "[Think Python: 3rd Edition](https://allendowney.github.io/ThinkPython/index.html)\n", |
| 1174 | + "\n", |
| 1175 | + "Copyright 2024 [Allen B. Downey](https://allendowney.com)\n", |
| 1176 | + "\n", |
| 1177 | + "Code license: [MIT License](https://mit-license.org/)\n", |
| 1178 | + "\n", |
| 1179 | + "Text license: [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-nc-sa/4.0/)" |
| 1180 | + ] |
1165 | 1181 | } |
1166 | 1182 | ], |
1167 | 1183 | "metadata": { |
|
0 commit comments