Before You Begin

This section contains information you should review before using this book. We’ll post updates at: http://www.deitel.com.

Font and Naming Conventions

We show Python code and commands and file and folder names in a sans-serif font, and on-screen components, such as menu names, in a bold sans-serif font. We use italics for emphasis and bold occasionally for strong emphasis.

Getting the Code Examples

You can download the examples.zip file containing the book’s examples from our Intro to Python for Computer Science and Data Science web page at:

http://www.deitel.com

Click the Download Examples link to save the file to your local computer. Most web browsers place the file in your user account’s Downloads folder. The examples are also available from Pearson’s Companion Website for the book at:

https://pearson.com/deitel

When the download completes, locate it on your system, and extract its examples folder into your user account’s Documents folder:

  • Windows: C:UsersYourAccountDocumentsexamples

  • macOS or Linux: ~/Documents/examples

Most operating systems have a built-in extraction tool. You also may use an archive tool such as 7-Zip (www.7-zip.org) or WinZip (www.winzip.com).

Structure of the examples Folder

You’ll execute three kinds of examples in this book:

  • Individual code snippets in the IPython interactive environment.

  • Complete applications, which are known as scripts.

  • Jupyter Notebooks—a convenient interactive, web-browser-based environment in which you can write and execute code and intermix the code with text, images and video.

We demonstrate each in Section 1.10’s test drives.

The examples folder contains one subfolder per chapter. These are named ch##, where ## is the two-digit chapter number 01 to 17—for example, ch01. Except for Chapters 14, 16 and 17, each chapter’s folder contains the following items:

  • snippets_ipynb—A folder containing the chapter’s Jupyter Notebook files.

  • snippets_py—A folder containing Python source code files in which each code snippet we present is separated from the next by a blank line. You can copy and paste these snippets into IPython or into new Jupyter Notebooks that you create.

  • Script files and their supporting files.

Chapter 14 contains one application. Chapters 16 and 17 explain where to find the files you need in the ch16 and ch17 folders, respectively.

Installing Anaconda

We use the easy-to-install Anaconda Python distribution with this book. It comes with almost everything you’ll need to work with our examples, including:

  • the IPython interpreter,

  • most of the Python and data science libraries we use,

  • a local Jupyter Notebooks server so you can load and execute our notebooks, and

  • various other software packages, such as the Spyder Integrated Development Environment (IDE)—we use only IPython and Jupyter Notebooks in this book.

Download the Python 3.x Anaconda installer for Windows, macOS or Linux from:

https://www.anaconda.com/download/

When the download completes, run the installer and follow the on-screen instructions. To ensure that Anaconda runs correctly, do not move its files after you install it.

Updating Anaconda

Next, ensure that Anaconda is up to date. Open a command-line window on your system as follows:

  • On macOS, open a Terminal from the Applications folder’s Utilities subfolder.

  • On Windows, open the Anaconda Prompt from the start menu. When doing this to update Anaconda (as you’ll do here) or to install new packages (discussed momentarily), execute the Anaconda Prompt as an administrator by right-clicking, then selecting More > Run as administrator. (If you cannot find the Anaconda Prompt in the start menu, simply search for it in the Type here to search field at the bottom of your screen.)

  • On Linux, open your system’s Terminal or shell (this varies by Linux distribution).

In your system’s command-line window, execute the following commands to update Anaconda’s installed packages to their latest versions:

  1. conda update conda

  2. conda update --all

Package Managers

The conda command used above invokes the conda package manager—one of the two key Python package managers you’ll use in this book. The other is pip. Packages contain the files required to install a given Python library or tool. Throughout the book, you’ll use conda to install additional packages, unless those packages are not available through conda, in which case you’ll use pip. Some people prefer to use pip exclusively as it currently supports more packages. If you ever have trouble installing a package with conda, try pip instead.

Installing the Prospector Static Code Analysis Tool

In the book’s exercises, we ask you to analyze Python code using the Prospector analysis tool, which checks your Python code for common errors and helps you improve your code. To install Prospector and the Python libraries it uses, run the following command in the command-line window:

pip install prospector

Installing jupyter-matplotlib

We implement several animations using a visualization library called Matplotlib. To use them in Jupyter Notebooks, you must install a tool called ipympl. In the Terminal, Anaconda Command Prompt or shell you opened previously, execute the following commands1 one at a time:

conda install -c conda-forge ipympl
conda install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib

Installing the Other Packages

Anaconda comes with approximately 300 popular Python and data science packages for you, such as NumPy, Matplotlib, pandas, Regex, BeautifulSoup, requests, Bokeh, SciPy, SciKit-Learn, Seaborn, Spacy, sqlite, statsmodels and many more. The number of additional packages you’ll need to install throughout the book will be small and we’ll provide installation instructions as necessary. As you discover new packages, their documentation will explain how to install them.

Get a Twitter Developer Account

If you intend to use our “Data Mining Twitter” chapter and any Twitter-based examples in subsequent chapters, apply for a Twitter developer account. Twitter now requires registration for access to their APIs. To apply, fill out and submit the application at

https://developer.twitter.com/en/apply-for-access

Twitter reviews every application. At the time of this writing, personal developer accounts were being approved immediately and company-account applications were taking from several days to several weeks. Approval is not guaranteed.

Internet Connection Required in Some Chapters

While using this book, you’ll need an Internet connection to install various additional Python libraries. In some chapters, you’ll register for accounts with cloud-based services, mostly to use their free tiers. Some services require credit cards to verify your identity. In a few cases, you’ll use services that are not free. In these cases, you’ll take advantage of monetary credits provided by the vendors so you can try their services without incurring charges. Caution: Some cloud-based services incur costs once you set them up. When you complete our case studies using such services, be sure to promptly delete the resources you allocated.

Slight Differences in Program Outputs

When you execute our examples, you might notice some differences between the results we show and your own results:

  • Due to differences in how calculations are performed with floating-point numbers (like –123.45, 7.5 or 0.0236937) across operating systems, you might see minor variations in outputs—especially in digits far to the right of the decimal point.

  • When we show outputs that appear in separate windows, we crop the windows to remove their borders.

Getting Your Questions Answered

Online forums enable you to interact with other Python programmers and get your Python questions answered. Popular Python and general programming forums include:

Also, many vendors provide forums for their tools and libraries. Most of the libraries you’ll use in this book are managed and maintained at github.com. Some library maintainers provide support through the Issues tab on a given library’s GitHub page. If you cannot find an answer to your questions online, please see our web page for the book at

http://www.deitel.com1

You’re now ready to begin reading Intro to Python for Computer Science and Data Sciences: Learning to Program with AI, Big Data and the Cloud. We hope you enjoy the book!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.210.17