Python for Programmers


Python for Programmers Paul Deitel and Harvey Deitel

Python for Programmers: with Big Data and Artificial Intelligence Case Studies This book, written for programmers with a high-level experience in another language, uses how-to instructions to teach the most compelling modern computing technologies and programming in Python, one of the world’s most popular and fastest-growing languages. Please read the front cover content chart and foreword for more details.


We’d like to thank Barbara Deitel for long hours devoted to Internet research on this project. We’re fortunate to have worked with the dedicated team of publishing professionals at Pearson. We appreciate the efforts and 25-year mentorship of our friend and colleague Mark L. Taub, Vice President of the Pearson IT Professional Group. Mark and his team publish our professional books, LiveLessons video products and Learning Paths in the Safari service ( They also sponsor our Safari live online training seminars. Julie Nahil managed the book’s production. We selected the cover art and Chuti Prasertsith designed the cover.

We wish to acknowledge the efforts of our reviewers. Patricia Byron-Kimball and Meghan Jacoby recruited the reviewers and managed the review process. Adhering to a tight schedule, the reviewers scrutinized our work, providing countless suggestions for improving the accuracy, completeness and timeliness of the presentation.

About the Authors

Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is an MIT graduate with 38 years of experience in computing. Paul is one of the world’s most experienced programming-languages trainers, having taught professional courses to software developers since 1992. He has delivered hundreds of programming courses to industry clients internationally, including Cisco, IBM, Siemens, Sun Microsystems (now Oracle), Dell, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, White Sands Missile Range, Rogue Wave Software, Boeing, Nortel Networks, Puma, iRobot and many more. He and his co-author, Dr. Harvey M. Deitel, are the world’s bestselling programming-language textbook/professional book/video authors.

Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 58 years of experience in computing. Dr. Deitel earned B.S. and M.S. degrees in Electrical Engineering from MIT and a Ph.D. in Mathematics from Boston University— he studied computing in each of these programs before they spun off Computer Science programs. He has extensive college teaching experience, including earning tenure and serving as the Chairman of the Computer Science Department at Boston College before founding Deitel & Associates, Inc., in 1991 with his son, Paul. The Deitels’ publications have earned international recognition, with more than 100 translations published in Japanese, German, Russian, Spanish, French, Polish, Italian, Simplified Chinese, Traditional Chinese, Korean, Portuguese, Greek, Urdu and Turkish. Dr. Deitel has delivered hundreds of programming courses to academic, corporate, government and military clients.

Welcome to Python—one of the world’s most widely used computer programming languages and, according to the Popularity of Programming Languages (PYPL) Index, the programming you’ll learn in Chapters 2–10 and the big-data, artificial-intelligence and cloud-based case studies we present in Chapters 11–16.

We’ll review object-oriented programming terminology and concepts. You’ll learn why Python has become so popular. We’ll introduce the Python Standard Library and various data-science libraries that help you avoid “reinventing the wheel.” You’ll use these libraries to create software objects that you’ll interact with to perform significant tasks with modest numbers of instructions.

Next, you’ll work through three test-drives showing how to execute Python code:

  • In the first, you’ll use IPython to execute Python instructions interactively and immediately see their results.
  • n the second, you’ll execute a substantial Python application that will display an animated bar chart summarizing rolls of a six-sided die as they occur. You’ll see the “Law of Large Numbers” in action. In Chapter 6, you’ll build this application with the Matplotlib visualization library.
  • In the last, we’ll introduce Jupyter Notebooks using JupyterLab—an interactive, web-browser-based tool in which you can conveniently write and execute Python instructions.
  • Jupyter Notebooks enable you to include text, images, audios, videos, animations and code.

    In the past, most computer applications ran on standalone computers (that is, not networked together). Today’s applications can be written with the aim of communicating among the world’s billions of computers via the Internet. We’ll introduce the Cloud and world’s most popular.

See also

Best laptop for Sims 4


Best laptop for Zoom


Best laptop for Minecraft


Best laptop for engineering student