Errata

Python: Learn Python in One Day and Learn It Well


Project: Math and BODMAS Page 76, Special Thanks to Andrew S. Neumann

Here we'll define our first function. Let's call it getUserPoint().

should be

Here we'll define our first function. Let's call it getUserScore().

Appendix A Page 94, Special Thanks to Herbie Wu

index() returns ValueError is sub is not found

should be

index() returns ValueError if sub is not found

Appendix A Page 99, Special Thanks to Herbie Wu

sep.join(myTuple)
 =>'d-e-f'

should be

sep.join(myList)
 =>'d-e-f'

Appendix E Page 116-117, Special Thanks to Andrew S. Neumann

Indentation of else-block for Exercise 3 is wrong

else:
   input = open('userScores.txt', 'r')
   output = open('userScores.tmp', 'w')
for line in input:
   content = line.split(',')
   if content[0] == userName:
      content[1] = score
      line = content[0] + ', ' + content[1] + '\n'

   output.write(line)
input.close()
output.close()

remove('userScores.txt')
rename('userScores.tmp', 'userScores.txt')

should be

else:
   input = open('userScores.txt', 'r')
   output = open('userScores.tmp', 'w')
   for line in input:
      content = line.split(',')
      if content[0] == userName:
         content[1] = score
         line = content[0] + ', ' + content[1] + '\n'

      output.write(line)
   input.close()
   output.close()

   remove('userScores.txt')
   rename('userScores.tmp', 'userScores.txt')

Appendix E Page 120, Special Thanks to Ernie Tam

if index > 0 and operatorList[index-1] != '**':
    operator = operatorDict[randint(1, 4)]
else:
    operator = operatorDict[randint(1, 5)]

should be

if index > 0 and operatorList[index-1] != '**':
    operator = operatorDict[randint(1, 5)]
else:
    operator = operatorDict[randint(1, 4)]

C#: Learn C# in One Day and Learn It Well

Update: 19 Mar 2017

Microsoft updated Visual Studio Community two weeks ago. If you are using the new version (VSC 2017), please select .Net desktop development  when installing (refer to screenshot below).


An updated version of the book was published in Mar 2017 to include new download instructions for VSC 2017. If you are using this updated version, please add one to the page numbers indicated below. Special Thanks to Daniel Rioux for highlighting this.

Chapter 2: Getting ready for C# Page 11, Special Thanks to James Czekaj

For instance, when you type a period (.) after the word “Console”, a dropdrop list appears to let you know what you can type after the period.

should be

For instance, when you type a period (.) after the word “Console”, a drop-down list appears to let you know what you can type after the period.

Chapter 3 Page 17, Special Thanks to Christian Sasso

float can store numbers from -3.4 x 1038 to +3.4 x 1038. It uses 8 bytes of storage and has a precision of approximately 7 digits.

should be

float can store numbers from -3.4 x 1038 to +3.4 x 1038. It uses 4 bytes of storage and has a precision of approximately 7 digits.

Chapter 5 Page 38, Special Thanks to Christian Sasso

The difference between WriteLine() and Write() is that Writeline() moves the cursor down to the next line after displaying the message while Write() does not.

should be

The difference between WriteLine() and Write() is that WriteLine() moves the cursor down to the next line after displaying the message while Write() does not.

Chapter 6 Page 51, Special Thanks to Ram Mitra and Jerry Myer

11 <= 7 is true

should be

11 <= 7 is false

Chapter 6 Page 56, Special Thanks to Christian Sasso
The pseudo code for the switch statement

switch (variable used for switching)
{
   case firstCase:
      do A;
      break (or other jump statements);
   case secondCase:
      do B;
      break (or other jump statements);
   case default:
      do C;
      break (or other jump statements);
}

should be

switch (variable used for switching)
{
   case firstCase:
      do A;
      break (or other jump statements);
   case secondCase:
      do B;
      break (or other jump statements);
   default:
      do C;
      break (or other jump statements);
}

Chapter 6 Page 67-68, Special Thanks to Ram Mitra

If you enter

10

You will get

Index was outside the bounds of the array.
Index should be from 0 to 5.

If you enter

Hello

You will get

Input string was not in a correct format.
You did not enter an integer.

should be

If you enter

10

You will get

Index should be from 0 to 5.

If you enter

Hello

You will get

You did not enter an integer.

Chapter 7 Page 72, Special Thanks to Stephen S. Baca

One of the main reasons is that using properties gives us greater control over what rights other classes have when assessing these private fields. We’ll see how to do that later.

should be

One of the main reasons is that using properties gives us greater control over what rights other classes have when accessing these private fields. We’ll see how to do that later.

Chapter 7 Page 78, Special Thanks to Ram Mitra

In C# (and most other languages), you can create two methods of the same name as long as they have different signatures.

should be

In C# (and most other languages), you can create two or more methods of the same name as long as they have different signatures.

Chapter 7 Page 82, Special Thanks to Ram Mitra

After creating our staff1 object, the next line shows how we can use the public EmployeeType property to assign a value to the hWorked field.

should be

After creating our staff1 object, the next line shows how we can use the public HoursWorked property to assign a value to the hWorked field.

Chapter 8 Page 101, Special Thanks to Ram Mitra

Now that we have seen an example of how inheritance woks

should be

Now that we have seen an example of how inheritance works

Chapter 8 Page 107, Special Thanks to Ram Mitra

Interfaces are much like abstract classes in that they cannot be instantiated and must be inherited.

should be

Interfaces are much like abstract classes in that they cannot be instantiated and must be inherited from.

Chapter 11 Page 126, Special Thanks to Jerry Myer and Ram Mitra

using(StreamWriter sw=new StreamWriter(path, true)) 
{ 
   sw.WriteLine("ABC"); 
   sw.WriteLine("DEF");
   sw.Close();
}

should be

using(StreamWriter sw=new StreamWriter(path, true)) 
{ 
   sw.WriteLine("ABC"); 
   sw.WriteLine("EFG");
   sw.Close();
}

Project: A Simple Payroll Software Page 129, Special Thanks to Ram Mitra

In addition to these three auto-implemented methods, the Staff class also has a public property called Hours Worked.

should be

In addition to these three auto-implemented properties, the Staff class also has a public property called Hours Worked.

Project Page 137, Special Thanks to Jerry Myer

Based on the value of result[1], we use an if statement to create a Manager object if the value of result[1] is “Manager” or an Admin object if the value is “Admin”.

should be

Based on the value of result[1], we use an if statement to create a Manager object if the value of result[1] is “Manager”, or an Admin object if the value is “Admin”.

A comma should be added before the words “or an Admin object”.


Appendix A – Project Answer Page 151, Special Thanks to Ram Mitra

For the Manager class:

The method below updates the total pay when HoursWorked is greater than 160. However, an allowance of 1000 is written in the payslip (even though it is not added to the manager’s total pay) when the manager has worked less than 160 hours.

public override void CalculatePay() 
{ 
   base.CalculatePay();

   Allowance = 1000;

   if (HoursWorked > 160) 
      TotalPay = BasicPay + Allowance; 
}

A better solution (provided by Ram Mitra) is:

public override void CalculatePay()
{
   base.CalculatePay();
   Allowance = 0;
   
   if (HoursWorked > 160)
   {
      Allowance = 1000;   
      TotalPay = BasicPay + Allowance;
   }
}

Appendix A – Project Answer Page 152, Special Thanks to Ram Mitra

For the Admin class:

public override void CalculatePay() 
{ 

   base.CalculatePay();
   if (HoursWorked > 160) 
      Overtime = overtimeRate * (HoursWorked - 160); 
}

should be

public override void CalculatePay() 
{ 

   base.CalculatePay();
   if (HoursWorked > 160) 
   {
      Overtime = overtimeRate * (HoursWorked - 160); 
      TotalPay = BasicPay + Overtime;
   } 
}

The line TotalPay = BasicPay + Overtime; is missing from the if-statement. This results in the total pay not being updated when HoursWorked is greater than 160.


CSS: Learn CSS in One Day and Learn It Well


Chapter 8 Page 107 Exercise 8.1 Paragraph 2, Special Thanks to Bruce Beach

The current font family is Sans Serif.

should be

The current font family is Serif.

Java: Learn Java in One Day and Learn It Well


Chapter 10: File Handling Page 162, Special Thanks to George Lykovitis

 line = reader.readerLine();.

should be

 line = reader.readLine();.

If you find any bugs/typo, please let me know. Thanks a million!