Need reviews for my book on introductory python

Ian Kelly ian.g.kelly at gmail.com
Fri Jan 27 18:12:14 EST 2017


On Jan 27, 2017 2:13 PM, "bob gailer" <bgailer at gmail.com> wrote:

On 1/26/2017 8:05 PM, Sandeep Nagar wrote:

> Hi
>
> As I mentioned, a scaled down version is available for free at
> bookmuft.Com which can be used to judge in this case.
>
Maybe I am blind, but I don't see any mention of bookmuft.Co.


I pulled up the PDF from bookmuft.com (which I also do not see mentioned in
the original post).

2.1 page 15:

"For example, suppose line 5 of a python program has syntax error, in this
case the program will executes all commands till line 4 and will then show
an error."

This is factually incorrect. A program with a syntax error will not be
executed at all.

The description of the Python interpreter is also pretty far from the
truth. The interpreter does not read Python source code one line at a time
as described. The interpreter only reads Python bytecode. At the point that
the interpreter starts reading bytecode, the Python compiler has already
compiled the entire source file into bytecode.

This description only applies to CPython. Other Python implementations may
work differently.

Page 17:

"When the programs compose of hundreds and thousands of lines, a
compilation process will yield a faster result because the object code
needs to be only compiled once and then run directly on microprocessor.
Whereas an interpreted code will check for interpretations each time it
needs to be processed."

Again, it's only Python byte code that is interpreted. The actual Python
source is compiled and does not need to be reprocessed each time a line of
code is executed.

3.2, page 21:

"logical: This type of data stores boolean values True or False boolean
values and can be operated by boolean operators like AND, OR etc."

The type is named "bool", not "logical".

"Most programming languages use the values 1 or 0 for boolean values but
python differs in this approach."

It's not really important, but I disagree with that assessment of "most
programming languages", at least in regard to modern or high-level ones.

3.3, page 22:

"There are four types of numeric data types" (listing int, long, float and
complex)

You left out Decimal and Fraction.

3.3.1: "Python has arbitrary precision for float, long, complex, hence the
limit to length of these numbers is subject to availability of memory"

Uh, no, that's only true for long. A Python float only has the same
precision as a C double. Same for complex but there are two components,
each with the precision of a C double.

3.3.2, page 24:

"The issue with floating point number based arithmetic is that the answer
is an approximation of real number since real numbers are defined for 10 as
their base whereas computer works with numbers where 2 is used as the base."

This is also incorrect. The definition of real numbers has nothing
whatsoever to do with base 10, and there are plenty of real numbers that
still could not be represented exactly even if float used decimal digits
instead of binary digits, and even if it did have arbitrary precision. For
example, 1/3. For another example, pi.

"Above calculation shows that 0.123_2 = 0.135_10."

Say what? First of all, 0.123 isn't even a valid number in binary. The only
digits available in base 2 are 0 and 1. Secondly, even if we ignore that,
the result of 1/2  + 2/2^2 + 3/2^3 = 1.375, not 0.135.

Page 25:

"One can use the decimal module which has a function Decimal() that returns
the number as stored by the computer."

That is not even close to an accurate description. First, Decimal is a
type, not a function. It differs from float in two important respects: one,
it uses a base-ten representation instead of base two; two, it actually
does have arbitrary precision. Also, it does not return the number as
stored by the computer. It's a completely separate implementation of real
numbers.

"As seen above, Decimal(0.123) occupies 72 bits and hence is more accurate
approximation as compared to 0.123 which occupies 24 bits"

Bytes, not bits. But also, Decimal(0.123) is no more accurate an
approximation than 0.123 because you constructed it from 0.123 which is
already an approximation. It's actually the exact same approximation.
Garbage in, garbage out. Decimal("0.123") on the other hand (note the use
of a string rather than a float as the constructor argument) denotes
exactly the real number 0.123.

3.4, page 26:

All of the information in this section about characters and encodings is
specific to strings and does not pertain to sequences generally.

"Python also deal with characters using data type string, list, tuple."

List and tuple have nothing to do with characters.

3.6, page 28:

"Mapping is a scheme of defining data where each element is identified with
a key called ”hash tag”."

I think you mean "hash value". A hash tag is something one uses when
posting on Twitter.

Page 29:

"In example above, we created a dictionary containing two characters a and
b identified by two keys 1 and 10."

In the example given, 'a' and 'b' are the keys and 1 and 10 are the values.

That's about all I have the energy for. These are the most egregious issues
that I've spotted, but there are loads of others that really need the
services of a professional editor. As it stands I wouldn't recommend this
book to anybody.



More information about the Python-list mailing list