Python Bootcamp A Rapid Crash Course Featuring Q&A Sessions, Exercises, and Projects — Vaskaran Sarcar
Python Bootcamp A Rapid Crash Course Featuring Q&A Sessions, Exercises, and Projects Vaskaran Sarcar
Python Bootcamp: A Rapid Crash Course Featuring Q&A Sessions, Exercises, and Projects ISBN-13 (pbk): 979-8-8688-1515-7 ISBN-13 (electronic): 979-8-8688-1516-4 https://doi.org/10.1007/979-8-8688-1516-4 Copyright © 2025 by Vaskaran Sarcar This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmis- sion or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Celestin Suresh John Development Editor: James Markham Editorial Assistant: Gryffin Winkler Cover designed by eStudioCalamar Cover image designed by Freepik (www.freepik.com) Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@ springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a Delaware LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail booktranslations@springernature.com; for reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub. For more detailed information, please visit https://github.com/ Apress/Python-Bootcamp. If disposing of this product, please recycle the paper Vaskaran Sarcar Kolkata, West Bengal, India
I dedicate this book to all the unsung heroes and volunteers who fought on the front lines of the COVID-19 battle to save humanity and this beautiful world.
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
xv About the Author Vaskaran Sarcar obtained his master’s in engineering from Jadavpur University, Kolkata (India), and his master’s in computer application from Vidyasagar University, Midnapore (India). He was a National Gate Scholar (2007-2009) and has over 12 years of experience in education and the IT industry. He devoted his early years (2005–2007) to the teaching profession at various engineering colleges, and later, he joined HP India PPS R&D Hub in Bangalore. He worked there for more than 10 years and became a senior software engineer and team lead. After that, he pursued his passion and has already authored 17 Apress books that can be found at the link amazon.com/ author/vaskaran_sarcar or the link https://link.springer.com/search? newsearch=true&query=vaskaran+sarcar&content-type=book&date From=&dateTo=&sortBy=newestFirst. You can also find him on LinkedIn at https://www.linkedin.com/in/vaskaransarcar.
xvii About the Technical Reviewer Shibsankar Das is currently working as a senior data scientist at Microsoft. He has more than 10 years of experience working in IT where he has led several data science initiatives, and in 2019, he was recognized as one of the top 40 data scientists in India. His core strength is in GenAI, Deep Learning, NLP, and Graph Neural Networks. Currently, he is focusing on his research on AI Agents and Knowledge Graph. He has experience working in the domain of foundational research, FinTech, and ecommerce. Before Microsoft, he has worked at Optum, Walmart, Envestnet, Microsoft Research, and Capgemini. He has pursued a master’s from the Indian Institute of Technology, Bangalore.
xix Acknowledgments At first, I thank the Almighty. I extend my deepest gratitude and thanks to the following people: Celestin and the Apress team: I sincerely thank each of you for giving me another opportunity to work with you and Apress. Shibsankar: I appreciate your time and effort in reviewing the book. Gryffin Winkler, Deepa Tryphosa, Jagathesan, Vinoth, and the copy editor Leah Bitong: Thanks to each of you for your exceptional support in this book’s development and for beautifying my work. Your efforts are extraordinary. Finally, I thank the Python community for sharing their knowledge in various forms. In fact, I thank everyone who directly or indirectly contributed to this work.
xxi Introduction Python Bootcamp: A Rapid Crash Course Featuring Q&A Sessions, Exercises, and Projects is an introductory guide to Python programming. To give you an overview of the book, let me highlight a few points: • The primary aim of this book is to make you familiar with Python programming as quickly as possible. I believe that you can enjoy learning when you analyze case studies, ask questions (about the doubts), and do some exercises. So, throughout this book, you will see interesting program segments, “Q&A sessions”, and exercises. By analyzing these Q&As and doing the exercises, you can verify your progress. As said before, these are presented to make your future learning easier and enjoyable, but most importantly, they make you confident as a developer. • Toward the end of each chapter, you’ll see the exercises. Chapter 3 onward, you’ll start solving case studies (a.k.a. projects). Once you finish reading the chapter, you’ll get the complete implementation of the projects. The exercises and case studies are neither too easy nor too tough. These are within your optimal zone of difficulty. These will help you test your understanding and raise your confidence level.
xxii • Each question in these Q&A sessions is marked with Q<Chapter_no>.<Question_no>. For example, Q2.1 means question number 1 from Chapter 2. Similarly, each question in these exercises is marked with E<Chapter_no>.<Question_no>. For example, E5.3 means exercise number 3 from Chapter 5. The case studies also have a similar format, but for them, you will see the prefix CS. For example, CS5.1 means case study 1 from Chapter 5. • Many of us are afraid of fat books because they do not promise that we can learn the subject in 1 day or 7 days. But you know that learning is a continuous process. It is hard to achieve any real mastery in 24 hours or 7 days. So the motto of the book is to learn the core topics of Python; whatever effort I need to put in, I am okay with that. Still, simple arithmetic says that if you can complete one chapter in 1 day, you can complete the book within 11 days (your learning speed depends only on your concentration level, focus, and dedication). But this arithmetic calculation is secondary! I have designed the book in such a way that upon completion of the book, you will know the core concepts in Python. Most importantly, you’ll know how to learn further. • Python is a very popular computer language and is widely used. Like other popular programming languages, it grows continuously to give us support with additional features and functionalities. In this book, you’ll see me using Python 3.13. At the time of this writing, it is the latest version. So everything in this book should run in Python 3.13 and upcoming versions. InTroduCTIon
xxiii How Is the Book Organized? The book has eleven chapters and three appendixes. Let me give you a quick overview of them: Chapter 1 is a warm-up session for you. Here, you’ll set up your programming environment and learn about code comments that will help you understand the programs better. Chapter 2 makes you familiar with variables and operators. Chapter 3 discusses the common data types such as strings, numbers, and Booleans. This chapter also helps you make interactive programs. Chapter 4 talks about decision-making in your program. Chapter 5 discusses iterations. Here, you’ll learn about loops and the usage of break and continue statements. Chapter 6 shows the usage of some advanced data types such as lists, tuples, and dictionaries. Chapter 7 teaches you how to use functions to make your code more Pythonic. It also discusses modules along with their usage. Chapter 8 talks about exceptions and how to manage them. Chapter 9 teaches you file-handling mechanisms. Chapters 10 and 11 briefly cover the object-oriented programming basics and show you the usage of classes, objects, and inheritance. Appendix A provides some extra material that was not discussed in the previous chapters. Appendix B suggests a list of recommended books, courses, and online resources that can help you learn more on this topic. Appendix C lists my other books. You can download the source code of the book from the link: https:// github.com/Apress/Python-Bootcamp. InTroduCTIon
xxiv Prerequisite Knowledge The target readers for this book are those who are new to Python programming. The book will be super easy for the readers with the least coding experience in any other high-level computer language. I assume that you can download a software installer following the instructions (or you have already installed Python on your computer). So I do not spend too much time on this topic. It is because you can find them easily both online and offline. Who Is This Book For? In short, you can pick the book if the answer is yes to the following questions: • Are you learning Python for the first time? • Do you want to explore the Python basics step by step but as quickly as possible? • Would you like to cover a brief overview of object- oriented programming and want to know how Python supports the concept? • Do you like to review your knowledge before you use Python in advanced fields such as data science and machine learning? You probably should not read this book if the answer is yes to any of the following questions: • Are you confident about the Python fundamentals? • Are you looking for the advanced concepts, excluding the topics mentioned previously? InTroduCTIon
Loading comments...
Reply to Comment
Edit Comment