Preface#

Many people often ask me how to learn Python. They come from different backgrounds, ages, and education levels, with most having no coding experience. They’re seeking a resource that’s easy to understand without getting into technical jargon. That’s the purpose of this online book. It explains Python concepts using simple language so that anyone, regardless of their field or expertise, can grasp it. After using this book, you’ll be able to understand and write medium-sized Python code.

There is a separate section on how to use Google Colaboratory to write and execute Python code. However, the code in this book can be used in any major Python editor. It is easy to use Google Colab because you do not need to install any program on your computer. It is also possible to write your code on a tablet and store it in your Google Drive. Also, Google Colab makes it possible to share your code and work on code as a group.

Each chapter of this book covers a Python subject along with optional items. You can skip the parts that might be too detailed for you. However, it is essential to write and execute all codes in this book yourself. Whenever you see code in this book, try to write it in your code editor and execute it. If possible, make some small changes to check your understanding. You can copy/paste the code, but for beginners, it is better to write the code yourself.

Additionally, the book includes debugging, output, coding, and exercises questions tailored for different proficiency levels.

  • Debugging: Identify errors within a given code.

    • These questions help you understand the syntax better and have an idea about the most common mistakes.

    • In these questions, first try to find mistakes, then think about how to solve them.

    • It is strongly recommended to write the correct code and execute it just to be sure it works well.

  • Output: Determine the output produced by a given code.

    • By solving these kinds of questions, you will be able to understand each small detail of a code.

    • The best way to solve these questions is to work on paper and not look at the solution until being sure about your answer.

    • Also, it is a great practice to try to change this code and write it in a different, and if possible, better or shorter way.

  • Coding: Write code for specific tasks.

    • This is the most important part to practice your coding skills with various types of questions.

    • The key point here is not looking at the solutions until having a solution, which might be even a partial one.

    • Please try to solve the questions in these sections by using the information only in the preceding chapters.

    • Keep in mind that there might be more than one solution for such kind of questions. The solutions in this book might not be the best ones because simple solutions have been chosen for this textbook.

  • Exercises: Write code to do certain tasks, but without given solutions. After becoming skilled at fixing errors, understanding outputs, and solving coding questions, it’s beneficial to tackle problems that don’t come with solutions. This part can also be used to assign homework to students. There is a dedicated subsection containing exercises focused on business applications.

The Projects part includes projects from various fields with suggestions for further work.

The Appendix part provides additional information on the topics covered in the book, including a section on visualization.

This book will be updated very often, and a project chapter will be added soon.

Yusuf Danisman, the author, is a faculty member in the Mathematics and Computer Science Department at Queensborough Community College, CUNY. He obtained his PhD in Mathematics from The Ohio State University and worked at the University of Oklahoma before joining CUNY. He teaches Mathematics, Statistics, Computer Science, and Data Science courses. Dr. Danisman is currently researching Financial Machine Learning and Geometric Deep Learning. He is also a steering committee member of the Northeast Big Data Innovation Hub.