After a lot of work reviewing the third edition (over six months) and adding new chapters, my book’s fourth edition, “Introduction to Programming with Python,” is now available. This journey started a long time ago; I believe I wrote Chapter 1 while on vacation in Fortaleza, Brazil, around 2003. The book was a distant project that I wanted to realize for a long time. The first edition was published in 2010 by Editora Novatec and since then, I’ve had the opportunity to work on three other editions.

Lançamento da quarta edição do livro. Capa com splash.

The second edition expanded the book’s content significantly, adding a chapter on SQL and relational databases. The third edition was a complete review of the text to close some gaps in explaining concepts and operations. All this was possible thanks to the feedback given by readers who always send suggestions, questions, and requests for corrections. As I’ve been following the Python groups in Brazil, I also collect many frequent questions and topics that seem more difficult to understand than others or require different explanations.

In the fourth edition, I finally managed to add a chapter on graphical interfaces, following the book’s tradition of working with the standard Python installation using tkinter. Programmers are now living in a world of web applications, but the need for desktop interface construction still exists. This topic is highly sought after in groups and I believe that explaining the main concepts will give readers the motivation they needed to venture into GUIs.

Another new chapter in this edition covers regular expressions and patterns in general. There’s a certain fascination among the community about using REGEX (regular expressions), but it’s an often-misunderstood topic. As the book is an introduction to programming, I was tempted to explain more formal concepts related to regular expressions, but these were added as links to sites where readers can find more information. The approach of the book is to show how to work with regular expressions without using them, only with Python code and gradually introduce the re module. I believe that by visualizing the code behind REGEX will give readers a clearer understanding of how they work. It also includes a part on patterns and the match instruction in Python, which is very interesting and goes beyond traditional switch-case statements.

Overall, each chapter has been updated with new material, but always with the goal of explaining how things work and where they can be used.

Even the first chapter was updated with new sections on how to solve problems and what to do when a solution isn’t found. One of the goals is to keep readers motivated, even when tackling more difficult parts, and resist the temptation to use ChatGPT.

The second chapter was revised to include the installation of VS Code and how to set it up for Portuguese Brazilian. However, the most significant change was the addition of a review of basic math. As many logic problems involve using some properties of the four operations, texts were added to remind readers about addition, multiplication, division, exponentiation, modulus, rule of three, and average calculation.

The fourth and fifth chapters were revised, and new images were added, mainly to show how code changes the program flow. These chapters are essential and form the basis of programming logic. Sections on trivia for talking a little about prime numbers and other topics were also added. These changes were made because many students saw basic concepts a long time ago in school or quickly realized them, but didn’t understand how to apply them in programming logic problems. New sections on reversing conditions and being careful when comparing values were also added.

The sixth chapter had several improvements in the existing text, as well as additional material about sets with figures demonstrating the main operations and new content for map, filter, and reduce. The seventh and eighth chapters also received many parts of the text revised and new materials to make them more Pythonic. A brush on functional programming was added, explaining how to translate some operations using list comprehensions and function application.

The ninth chapter received a lot of new material, including detailed explanations about how the command line works in Linux and Windows. The pathlib module was also added. Additionally, a section on reading and writing JSON files was added. What I liked most, however, was the part about binary files, where using Python, we create BMP files from text.

The tenth chapter received many revisions, including an introductory section to explain how some operations were done without objects, helping to cover the distance between procedural programming and object-oriented programming. New examples, the use of UserList, and various materials that helped readers deepen their knowledge were also added.

The eleventh chapter on databases was less changed; given the nature of the SQL language, its content is stable, only minor corrections were made.

The twelfth chapter is about regular expressions and pattern matching, completely new. The idea is to show how code would be without regular expressions and then with regular expressions. I hope it will help readers better understand this often-misunderstood topic.

The thirteenth chapter deals with graphical interfaces using tkinter, which is also completely new. This chapter has three example applications: a simple data entry application to illustrate the basic concepts such as clicks and window changes; a program for drawing on the screen with the mouse and a link manager that saves data in a JSON file.

The fourteenth chapter was updated, and the links were revised with more information about new libraries.

A surprise for electronics and computer science students is a new appendix that talks about bit-by-bit operators using Python.

I created a PDF that serves as a map of the main changes and improvements in the fourth edition. It’s quite large; use the zoom function of your PDF viewer to navigate, I don’t recommend printing it because it will be very small and hard to read. The PDF can be downloaded here. Click here to download the summary.

I’d like to make it clear that this work wasn’t done by just one person. The review involved participation from my family, especially my wife and daughter, who helped a lot with revisions and corrections. In addition to feedback from friends about the book and their experience in class, readers who send emails with questions, and active groups; Rubens Prates, editor at Novatec, also helped a lot by guiding on what not to put in the book, maintaining focus, and correcting all material.

Livro Introdução à Programação com Python - Quarta Edição - capa

ISBN 978-85-7522-886-9 Price: R$129.00

Until 31/03/24, with the code PYTHON4ED, you get a 25% discount on the publisher’s website

This year, I plan to publish more videos and tips; you can follow:

I hope you all like the change, the book is with 552 pages teaching programming logic but also important resources of Python language.