# The Quick Python Book

![](https://3650666907-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M16IoaANYRvc0I-U9uw%2F-M4hdeUUcNO3qZTh_dVw%2F-M4hePPfvM7gAAr0f5WS%2Fimage.png?alt=media\&token=c880f3f4-f5fb-48ae-84bf-8f33c68b1045)

## [About this book](https://livebook.manning.com/book/the-quick-python-book-third-edition/case-study/) <a href="#pref05" id="pref05"></a>

The Quick Python Book, Third Edition, is intended for people who already have experience in one or more programming languages and want to learn the basics of Python 3 as quickly and directly as possible. Although some basic concepts are covered, there’s no attempt to teach fundamental programming skills in this book, and the basic concepts of flow control, OOP, file access, exception handling, and the like are assumed. This book may also be of use to users of earlier versions of Python who want a concise reference for Python 3.

#### How to use this book <a href="#pref05lev1sec1" id="pref05lev1sec1"></a>

[Part 1](https://livebook.manning.com/book/the-quick-python-book-third-edition/part-1/part01) introduces Python and explains how to download and install it on your system. It also includes a very general survey of the language, which will be most useful for experienced programmers looking for a high-level view of Python.

[Part 2](https://livebook.manning.com/book/the-quick-python-book-third-edition/part-2/part02) is the heart of the book. It covers the ingredients necessary for obtaining a working knowledge of Python as a general-purpose programming language. The chapters are designed to allow readers who are beginning to learn Python to work their way through sequentially, picking up knowledge of the key points of the language. These chapters also contain some more-advanced sections, allowing you to return to find in one place all the necessary information about a construct or topic.

[Part 3](https://livebook.manning.com/book/the-quick-python-book-third-edition/part-3/part03) introduces advanced language features of Python—elements of the language that aren’t essential to its use but that can certainly be a great help to a serious Python programmer.

[Part 4](https://livebook.manning.com/book/the-quick-python-book-third-edition/part-4/part04) describes more-advanced or specialized topics that are beyond the strict syntax of the language. You may read these chapters or not, depending on your needs.

A suggested plan if you’re new to Python programming is to start by reading [chapter 3](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-3/ch03) to obtain an overall perspective and then work through the chapters in [part 2](https://livebook.manning.com/book/the-quick-python-book-third-edition/part-2/part02) that are applicable. Enter in the interactive examples as they are introduced to immediately reinforce the concepts. You can also easily go beyond the examples in the text to answer questions about anything that may be unclear. This has the potential to amplify the speed of your learning and the level of your comprehension. If you aren’t familiar with OOP or don’t need it for your application, skip most of [chapter 15](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-15/ch15).

Those who are familiar with Python should also start with [chapter 3](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-3/ch03). It’s a good review and introduces differences between Python 3 and what may be more familiar. It’s also a reasonable test of whether you’re ready to move on to the advanced chapters in [parts 3](https://livebook.manning.com/book/the-quick-python-book-third-edition/part-3/part03) and [4](https://livebook.manning.com/book/the-quick-python-book-third-edition/part-4/part04) of this book.

It’s possible that some readers, although new to Python, will have enough experience with other programming languages to be able to pick up the bulk of what they need to get going by reading [chapter 3](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-3/ch03) and by browsing the Python standard library modules listed in [chapter 19](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-19/ch19) and the Python Library Reference in the Python documentation.

#### Roadmap <a href="#pref05lev1sec2" id="pref05lev1sec2"></a>

[Chapter 1](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-1/ch01) discusses the strengths and weaknesses of Python and shows why Python 3 is a good choice of programming language for many situations.

[Chapter 2](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-2/ch02) covers downloading, installing, and starting up the Python interpreter and IDLE, its integrated development environment.

[Chapter 3](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-3/ch03) is a short overview of the Python language. It provides a basic idea of the philosophy, syntax, semantics, and capabilities of the language.

[Chapter 4](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-4/ch04) starts with the basics of Python. It introduces Python variables, expressions, strings, and numbers. It also introduces Python’s block-structured syntax.

[Chapters 5](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-5/ch05), [6](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-6/ch06), and [7](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-7/ch07) describe the five powerful built-in Python data types: lists, tuples, sets, strings, and dictionaries.

[Chapter 8](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-8/ch08) introduces Python’s control flow syntax and use (loops and if-else statements).

[Chapter 9](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-9/ch09) describes function definition in Python along with its flexible parameter-passing capabilities.

[Chapter 10](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-10/ch10) describes Python modules, which provide an easy mechanism for segmenting the program namespace.

[Chapter 11](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-11/ch11) covers creating standalone Python programs, or scripts, and running them on Windows, macOS, and Linux platforms. The chapter also covers the support available for command-line options, arguments, and I/O redirection.

[Chapter 12](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-12/ch12) describes how to work with and navigate through the files and directories of the filesystem. It shows how to write code that’s as independent as possible of the actual operating system you’re working on.

[Chapter 13](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-13/ch13) introduces the mechanisms for reading and writing files in Python, including the basic capability to read and write strings (or byte streams), the mechanism available for reading binary records, and the ability to read and write arbitrary Python objects.

[Chapter 14](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-14/ch14) discusses the use of exceptions, the error-handling mechanism used by Python. It doesn’t assume that you have any previous knowledge of exceptions, although if you’ve previously used them in C++ or Java, you’ll find them familiar.

[Chapter 15](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-15/ch15) introduces Python’s support for writing object-oriented programs.

[Chapter 16](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-16/ch16) discusses the regular-expression capabilities available for Python.

[Chapter 17](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-17/ch17) introduces more-advanced OOP techniques, including the use of Python’s special method-attributes mechanism, metaclasses, and abstract base classes.

[Chapter 18](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-18/ch18) introduces the package concept in Python for structuring the code of large projects.

[Chapter 19](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-19/ch19) is a brief survey of the standard library. It also includes a discussion of where to find other modules and how to install them.

[Chapter 20](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-20/ch20) dives deeper into manipulating files in Python.

[Chapter 21](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-21/ch21) covers strategies for reading, cleaning, and writing various types of data files.

[Chapter 22](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-22/ch22) surveys the process, issues, and tools involved in fetching data over the network.

[Chapter 23](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-23/ch23) discusses how Python accesses relational and NoSQL databases.

[Chapter 24](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-24/ch24) is a brief introduction to using Python, Jupyter notebook, and pandas to explore data sets.

The case study walks you through using Python to fetch data, clean it, and then graph it. The project combines several features of the language discussed in the chapters, and it gives you a chance to a see a project worked through from beginning to end.

[Appendix A](https://livebook.manning.com/book/the-quick-python-book-third-edition/appendix-a/app02) contains a guide to obtaining and accessing Python’s full documentation, the Pythonic style guide, PEP 8, and “[The Zen of Python](https://livebook.manning.com/book/the-quick-python-book-third-edition/appendix-a/app02lev1sec5),” a slightly wry summary of the philosophy behind Python.

[Appendix B](https://livebook.manning.com/book/the-quick-python-book-third-edition/appendix-b/app03) has the answers to most of the exercises. In a few cases, the exercises ask you to experiment on your own. I don’t attempt to provide answers for those exercises.

#### Code conventions <a href="#pref05lev1sec3" id="pref05lev1sec3"></a>

The code samples in this book, and their output, appear in a fixed-width font and are often accompanied by annotations. The code samples are deliberately kept as simple as possible, because they aren’t intended to be reusable parts that can be plugged into your code. Instead, the code samples are stripped down so that you can focus on the principle being illustrated.

In keeping with the idea of simplicity, the code examples are presented as interactive shell sessions where possible; you should enter and experiment with these samples as much as you can. In interactive code samples, the commands that need to be entered are on lines that begin with the >>> prompt, and the visible results of that code (if any) are on the line below.

In some cases a longer code sample is needed, and these cases are identified in the text as file listings. You should save these listings as files with names matching those used in the text and run them as standalone scripts.

#### Exercises <a href="#pref05lev1sec4" id="pref05lev1sec4"></a>

Starting in [chapter 4](https://livebook.manning.com/book/the-quick-python-book-third-edition/chapter-4/ch04), this book provides three kinds of exercises. The Quick Check exercises are very brief questions that encourage you to pause and make sure you’re clear on an idea just presented. The Try This exercises are a bit more demanding and usually suggest that you try your hand at some Python code. At the end of many chapters is a Lab, which gives you a chance to put the concepts of the current and previous chapters together for a complete script.

#### Exercise answers <a href="#pref05lev1sec5" id="pref05lev1sec5"></a>

Answers to most of the exercises are available in [appendix B](https://livebook.manning.com/book/the-quick-python-book-third-edition/appendix-b/app03) and are also included in a separate directory along with the book’s source code. Keep in mind that the answers are not meant to be the only answers for the coding problems; there may be several other approaches. The best way to judge your answers is to understand what the suggested answer does and then decide whether your answer achieves the same end.

#### Source code downloads <a href="#pref05lev1sec6" id="pref05lev1sec6"></a>

The source code for the samples in this book is available from the publisher’s website at [www.manning.com/books/the-quick-python-book-third-edition](http://www.manning.com/books/the-quick-python-book-third-edition).

#### System requirements <a href="#pref05lev1sec7" id="pref05lev1sec7"></a>

The samples and code in this book have been written with Windows (Windows 7 through 10), macOS, and Linux in mind. Because Python is a cross-platform language, the samples and code should work on other platforms for the most part, except for platform-specific issues, such as the handling of files, paths, and GUIs.

#### Software requirements <a href="#pref05lev1sec8" id="pref05lev1sec8"></a>

This book is based on Python 3.6, and all examples should work on any subsequent version of Python 3. (Most have been tested with a prerelease version of Python 3.7.) With a few exceptions, the examples also work on Python 3.5, but I strongly recommend using 3.6; there are no advantages to using the earlier version, and 3.6 has several subtle improvements. Note that Python 3 is required and that an earlier version of Python will not work with the code in this book.

#### Book forum <a href="#pref05lev1sec9" id="pref05lev1sec9"></a>

The purchase of The Quick Python Book, Third Edition, includes free access to a private web forum run by Manning Publications, where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum, go to [https://forums.manning.com/forums/the-quick-python-book-third-edition](https://forums.manning.com/forums/the-quick-python-book-third-edition). You can also learn more about Manning’s forums and the rules of conduct at [https://forums.manning.com/forums/about](https://forums.manning.com/forums/about).

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It’s not a commitment to any specific amount of participation on the part of the author, whose contribution to the book’s forum remains voluntary (and unpaid). We suggest that you try asking her some challenging questions, lest her interest stray!

The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

#### About the author <a href="#pref05lev1sec10" id="pref05lev1sec10"></a>

NAOMI CEDER, the author of this third edition, has been programming in various languages for nearly 30 years and has been a Linux system administrator, programming teacher, developer, and system architect. She started using Python in 2001, and since then has taught Python to users at all levels, from 12-year-olds to professionals. She gives talks on Python and the benefits of an inclusive community to whomever will listen. Naomi currently leads a development team for Dick Blick Art Materials and is the chair of the Python Software Foundation.



Reference : [https://livebook.manning.com/book/the-quick-python-book-third-edition/about-this-book/](https://livebook.manning.com/book/the-quick-python-book-third-edition/about-this-book/)
