ran everything through aspell to pick up typos; standardised to Briti… · confluence/python-textbok@3e25e3a · GitHub
Skip to content

Commit 3e25e3a

Browse files
committed
ran everything through aspell to pick up typos; standardised to British spelling (except for code); consistent use of floating-point as an adjective
1 parent 3ecaa16 commit 3e25e3a

8 files changed

Lines changed: 22 additions & 22 deletions

python_notes/Classes.rst

Lines changed: 2 additions & 2 deletions

python_notes/Errors_and_Exceptions.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Sometimes there can be absolutely nothing wrong with your Python implementation
7575

7676
* using the wrong variable name
7777
* indenting a block to the wrong level
78-
* using integer division instead of floating point division
78+
* using integer division instead of floating-point division
7979
* getting operator precedence wrong
8080
* making a mistake in a boolean expression
8181
* off-by-one, and other numerical errors
@@ -121,7 +121,7 @@ Handling exceptions
121121

122122
Until now, the programs that we have written have generally ignored the fact that things can go wrong. We have have tried to prevent runtime errors by checking data which may be incorrect before we used it, but we haven't yet seen how we can handle errors when they do occur -- our programs so far have just crashed suddenly whenever they have encountered one.
123123

124-
There are some situations in which runtime errors are likely to occur. Whenever we try to read a file or get input from a user, there is a chance that something unexpected will happen -- the file may have been moved or deleted, and the user may enter data which is not in the right format. Good programmers should add safeguards to their programs so that common situations like this can be handled gracefully -- a program which crashes whenever it encounters an easily forseeable problem is not very pleasant to use. Most users expect programs to be robust enough to recover from these kinds of setbacks.
124+
There are some situations in which runtime errors are likely to occur. Whenever we try to read a file or get input from a user, there is a chance that something unexpected will happen -- the file may have been moved or deleted, and the user may enter data which is not in the right format. Good programmers should add safeguards to their programs so that common situations like this can be handled gracefully -- a program which crashes whenever it encounters an easily foreseeable problem is not very pleasant to use. Most users expect programs to be robust enough to recover from these kinds of setbacks.
125125

126126
If we know that a particular section of our program is likely to cause an error, we can tell Python what to do if it does happen. Instead of letting the error crash our program we can intercept it, do something about it, and allow the program to continue.
127127

@@ -491,7 +491,7 @@ Answer to exercise 1
491491

492492
#.
493493

494-
#. The values entered by the user may not be valid integers or floating point numbers.
494+
#. The values entered by the user may not be valid integers or floating-point numbers.
495495
#. The user may enter zero for the divisor.
496496
#. If the ``math`` library hasn't been imported, ``math.round`` is undefined.
497497

@@ -620,4 +620,4 @@ Answer to exercise 4
620620
logging.info("%s already has %d elements." % (listname, len(l)))
621621
finally:
622622
thedict[listname].append(element)
623-
logging.info("Added %s to %s." % (element, listname))
623+
logging.info("Added %s to %s." % (element, listname))

python_notes/Functions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Remember that although we can execute a function *body* many times, a function *
323323
Exercise 4
324324
----------
325325

326-
#. Write a function called ``calculator``. It should take the following parameters: two numbers, an arithmetic operation (which can be addition, subtraction, multiplication or division and is addition by default), and an output format (which can be integer or floating point, and is floating point by default). Division should be floating point division.
326+
#. Write a function called ``calculator``. It should take the following parameters: two numbers, an arithmetic operation (which can be addition, subtraction, multiplication or division and is addition by default), and an output format (which can be integer or floating point, and is floating point by default). Division should be floating-point division.
327327

328328
The function should perform the requested operation on the two input numbers, and return a result in the requested format (if the format is integer, the result should be rounded and not just truncated). Raise exceptions as appropriate if any of the parameters passed to the function are invalid.
329329

@@ -363,7 +363,7 @@ We can use ``*`` or ``**`` when we are *calling* a function to *unpack* a sequen
363363
my_dict = {"name": "Jane", "surname": "Doe"}
364364
print_kwargs(**my_dict)
365365

366-
This makes it easier to build lists of parameters programatically. Note that we can use this for *any* function, not just one which uses ``*args`` or ``**kwargs``::
366+
This makes it easier to build lists of parameters programmatically. Note that we can use this for *any* function, not just one which uses ``*args`` or ``**kwargs``::
367367

368368
my_dict = {
369369
"title": "Mr",

python_notes/Loop_Control_Statements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Exercise 2
190190

191191
#. Write a program which finds the factorial of a given number. E.g. 3 factorial, or **3!** is equal to **3 x 2 x 1**; **5!** is equal to **5 x 4 x 3 x 2 x 1**, etc.. Your program should only contain a single loop.
192192

193-
#. Write a program which prompts the user for 10 floating point numbers and calculates their sum, product and average. Your program should only contain a single loop.
193+
#. Write a program which prompts the user for 10 floating-point numbers and calculates their sum, product and average. Your program should only contain a single loop.
194194

195195
#. Rewrite the previous program so that it has two loops -- one which collects and stores the numbers, and one which processes them.
196196

python_notes/Python_Basics.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ results in an integer solution.
655655

656656
.. Note:: In Python 2, the operator ``/`` performed integer division
657657
if both the dividend and the divisor were integers, and
658-
floating point division if at least one of them was a float.
658+
floating-point division if at least one of them was a float.
659659
In Python 3, ``/`` *always* performs floating-point division
660660
and ``//`` *always* performs integer division -- even if the
661661
dividend and divisor are floats!
@@ -739,7 +739,7 @@ Floating-point numbers
739739
Floating-point numbers (``float`` type) are numbers with a decimal
740740
point or an exponent (or both). Examples are ``5.0``, ``10.24``,
741741
``0.0``, ``12.`` and ``.3``. We can use scientific notation to denote
742-
very large or very small floating point numbers, e.g. 3.8 x 10\
742+
very large or very small floating-point numbers, e.g. 3.8 x 10\
743743
:sup:`15`. The first part of the number, 3.8, is the mantissa and 15
744744
is the exponent. We can think of the exponent as the number of times
745745
we have to move the decimal point to the right to get to the actual
@@ -808,18 +808,18 @@ the order of precedence.
808808

809809
.. Note::
810810

811-
Python floating-point numbers confirm to standardized format named
811+
Python floating-point numbers conform to a standardised format named
812812
``IEEE 754``. The standard represents each floating-point number
813813
using a small fixed amount of memory, so unlike Python's integers,
814-
Python's floating point numbers have a limited range. The largest
814+
Python's floating-point numbers have a limited range. The largest
815815
floating-point number that can be represented in Python is
816816
``2**1023``.
817817

818818
.. Note::
819819

820820
Python includes three other types for dealing with numbers:
821821

822-
* ``complex`` (like floating-point but for complex numbers; try
822+
* ``complex`` (like floating point but for complex numbers; try
823823
``1+5j``)
824824
* ``Fraction`` (for rational numbers; available in the ``fractions``
825825
module)
@@ -836,9 +836,9 @@ Exercise 5
836836
``1.0``, ``1.12e4``, ``-3.141759``, ``735``, ``0.57721566``,
837837
``7.5e-3``
838838

839-
#. What is the difference between integer and floating point division?
839+
#. What is the difference between integer and floating-point division?
840840
What is the operator used for integer division? What is the
841-
operator used for floating point division?
841+
operator used for floating-point division?
842842

843843
#. What are the results of the following operations? Explain why:
844844
#. ``1.5 + 2``

python_notes/Selection_Control_Statements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ The following code fragment will print out a message if the given age is less th
465465
if age < 0 or age > 120:
466466
print("Invalid age: %d" % age)
467467

468-
The interpreter also performs a short-circuit evaluation for ``or`` expressions. If it evaluates the first subexpression to be true, it will not bother to evaluate the second, because this is suffifent to determine that the whole expression is true.
468+
The interpreter also performs a short-circuit evaluation for ``or`` expressions. If it evaluates the first subexpression to be true, it will not bother to evaluate the second, because this is sufficient to determine that the whole expression is true.
469469

470470
The || operator is also binary::
471471

python_notes/Sorting_and_Searching_Algorithms.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ likely to be many possible algorithms which can perform the same task.
1212
Are some of these algorithms in some sense better than others?
1313
Algorithm analysis is the study of this question.
1414

15-
In this chapter we will analyze four algorithms; two for each of the
15+
In this chapter we will analyse four algorithms; two for each of the
1616
following common tasks:
1717

1818
* *sorting*: ordering a list of values
@@ -511,14 +511,14 @@ Python's sorting algorithm
511511
Python's default sorting algorithm, which is used by the built-in
512512
``sorted`` function as well as the ``sort`` method of list objects, is
513513
called *Timsort*. It's an algorithm developed by Tim Peters in 2002 for
514-
use in Python. Timsort is a modifed version of merge sort which uses
514+
use in Python. Timsort is a modified version of merge sort which uses
515515
insertion sort to arrange the list of items into conveniently mergeable
516516
sections.
517517

518518
.. Note::
519519

520520
Tim Peters is also credited as the author of *The Zen of Python* --
521-
an attempt to summarize the early Python community's ethos in a
521+
an attempt to summarise the early Python community's ethos in a
522522
short series of koans. You can read it by typing ``import this``
523523
into the Python console.
524524

python_notes/Variables_and_Scope.rst

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)