Previous Next

BiteSize Python for Absolute Beginners With Practice Labs, Real-World Examples, and Generative AI Assistance (Di Wu)(Z-Library)

Author: Di Wu

技术

As an introduction to Python, this book allows readers to take a slow and steady approach to understanding Python code, explaining concepts, connecting programming with real-life examples, writing Python programs, and completing case studies. While there are many books, websites, and online courses about the topic, we break down Python programming into easily digestible lessons of less than 5 minutes each, following our BiteSize approach. Each lesson begins with a clear and short introduction to the topic. This gives you a strong base to start from and gets you ready for deeper learning. Then, you will see coding demonstrations that show the ideas discussed. These examples are simple and useful, helping you really understand the concepts. You’ll then practice tasks at different difficulty levels, so you can test your knowledge and increase your confidence. You’ll also play with case studies to solve real-world problems. Tips are included to show how you can incorporate generative AI into your learning toolkit, using it for feedback, practice exercises, code reviews, and exploring advanced topics. Recommended AI prompts can help you identify areas for improvement, review key concepts, and track your progress. This book is designed for absolute beginners with no prior programming experience. It is ideal for individuals with busy schedules or limited time for studying.

📄 File Format: PDF
💾 File Size: 9.1 MB
25
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
(This page has no text content)
📄 Page 2
BiteSize Python for Absolute Beginners While there are many books, websites, and online courses about the topic, we break down Py- thon programming into easily digestible lessons of less than 5 minutes each, following our Bi- teSize approach. Each lesson begins with a clear and short introduction to the topic. This gives you a strong base to start from and gets you ready for deeper learning. Then, you will see coding demonstrations that show the ideas discussed. These examples are simple and useful, helping you really understand the concepts. You’ll then practice tasks at different difficulty levels, so you can test your knowledge and increase your confidence. You’ll also play with case studies to solve real-world problems. Tips are included to show how you can incorporate generative AI into your learning toolkit, using it for feedback, practice exercises, code reviews, and exploring advanced topics. Recommended AI prompts can help you identify areas for improvement, review key con- cepts, and track your progress. This book is designed for absolute beginners with no prior programming experience. It is ideal for individuals with busy schedules or limited time for studying. As an introduction to Python, this book allows readers to take a slow and steady approach to understanding Python code, explaining concepts, connecting programming with real-life examples, writing Python programs, and completing case studies.
📄 Page 3
Chapman & Hall/CRC The Python Series About the Series Python has been ranked as the most popular programming language, and it is widely used in education and in- dustry. This book series will offer a wide range of books on Python for students and professionals. Titles in the series will help users learn the language at an introductory and advanced level, and explore its many applica- tions in data science, AI, and machine learning. Series titles can also be supplemented with Jupyter notebooks. Statistics and Data Visualisation with Python Jesús Rogel-Salazar Introduction to Python for Humanists William J.B. Mattingly Python for Scientific Computation and Artificial Intelligence Stephen Lynch Learning Professional Python Volume 1: The Basics Usharani Bhimavarapu and Jude D. Hemanth Learning Professional Python Volume 2: Advanced Usharani Bhimavarapu and Jude D. Hemanth Learning Advanced Python from Open Source Projects Rongpeng Li Foundations of Data Science with Python John Mark Shea Data Mining with Python: Theory, Applications, and Case Studies Di Wu A Simple Introduction to Python  Stephen Lynch Introduction to Python: with Applications in Optimization, Image and Video Processing, and Machine Learning David Baez-Lopez and David Alfredo Báez Villegas Tidy Finance with Python Christoph Frey, Christoph Scheuch, Stefan Voigt and Patrick Weiss Introduction to Quantitative Social Science with Python Weiqi Zhang and Dmitry Zinoviev Python Programming for Mathematics Julien Guillod Geocomputation with Python Michael Dorman, Anita Graser, Jakub Nowosad and Robin Lovelace BiteSize Python for Absolute Beginners: With Practice Labs, Real-World Examples, and Generative AI Assistance Di Wu For more information about this series please visit: https://www.routledge.com/Chapman--HallCRC-The- Python-Series/book-series/PYTH
📄 Page 4
BiteSize Python for Absolute Beginners With Practice Labs, Real-World Examples, and Generative AI Assistance Di Wu
📄 Page 5
Designed cover image: Shutterstock MATLAB® and Simulink® are trademarks of The MathWorks, Inc. and are used with permission. The MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB® or Simulink® software or related products does not constitute endorsement or sponsorship by The MathWorks of a particular peda- gogical approach or particular use of the MATLAB® and Simulink® software. First edition published 2026 by CRC Press 2385 NW Executive Center Drive, Suite 320, Boca Raton FL 33431 and by CRC Press 4 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN CRC Press is an imprint of Taylor & Francis Group, LLC © 2026 Di Wu Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot as- sume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including pho- tocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, access www.copyright.com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. For works that are not available on CCC please contact mpkbookspermissions@tandf.co.uk Trademark notice: Product or corporate names may be trademarks or registered trademarks and are used only for iden- tification and explanation without intent to infringe. ISBN: 978-1-032-86488-4 (hbk) ISBN: 978-1-032-86485-3 (pbk) ISBN: 978-1-003-52772-5 (ebk) DOI: 10.1201/9781003527725 Typeset in Nimbus Roman by KnowledgeWorks Global Ltd.
📄 Page 6
To my wife.
📄 Page 7
(This page has no text content)
📄 Page 8
Contents List of Figures xvii List of Tables xix Foreword xxi Preface xxiii Author Bios xxvii Section I Python Fundamentals Chapter 1 ■ Introduction to Python 3 1.1 WHAT IS PYTHON? 3 1.2 WHY PYTHON? 4 1.3 SCRIPT VERSUS INTERACTIVE PYTHON 4 1.4 WHY INTERACTIVE PYTHON? 5 1.5 JUPYTER 6 1.6 LOCAL OR CLOUD 7 1.7 LEARNING PYTHON 8 Chapter 2 ■ Input and Output 10 2.1 HELLO, WORLD! 10 2.1.1 Demonstration 10 2.1.2 Practice 11 2.2 SINGLE OR DOUBLE 11 2.2.1 Explanation 11 2.2.2 Demonstration 12 2.2.3 Practice 12 2.3 TRIPLE QUOTATIONS 13 2.3.1 Explanation 13 vii
📄 Page 9
viii ■ Contents 2.3.2 Practice 14 2.4 PRINT MULTIPLE VALUES 15 2.4.1 Demonstration 15 2.4.2 Practice 15 2.5 INTERACT WITH GENAI 15 2.6 GET INPUTS 16 2.6.1 Demonstration 16 2.6.2 Practice 16 2.7 COMBINE PRINT() AND INPUT() 17 2.7.1 Explanation 17 2.7.2 Demonstration 17 2.7.3 Practice 17 2.8 INTERACT WITH GENAI 18 Chapter 3 ■ Variables 19 3.1 WHAT ARE VARIABLES 19 3.1.1 Explanation 19 3.1.2 Practice 20 3.2 NAMING RULES 20 3.2.1 Explanation 20 3.2.2 Practice 21 3.3 DATA TYPES 21 3.3.1 Explanation 21 3.3.2 Practice 22 3.4 DATA TYPES CONVERT 23 3.4.1 Explanation 23 3.4.2 Demonstration 23 3.4.3 Practice 24 3.5 INTERACT WITH GENAI 25 Chapter 4 ■ Operations 26 4.1 ASSIGNMENT OPERATIONS 26 4.1.1 Explanation 26 4.1.2 Practice 27 4.2 ARITHMETIC OPERATIONS 27 4.2.1 Explanation 27 4.2.2 Demonstration 28
📄 Page 10
Contents ■ ix 4.2.3 Practice 29 4.3 RELATIONAL OPERATIONS 30 4.3.1 Explanation 30 4.3.2 Practice 30 4.4 LOGICAL OPERATIONS 31 4.4.1 Explanation 31 4.4.2 Practice 32 4.5 INTERACT WITH GENAI 34 Chapter 5 ■ String 36 5.1 WHAT IS STR? 36 5.1.1 Explanation 36 5.1.2 Thinking 36 5.2 STRING CREATION 36 5.2.1 Demonstration 37 5.3 STRING ACCESS 37 5.3.1 Demonstraton 37 5.3.2 Practice 39 5.4 STRING SLICING 40 5.4.1 Demonstration 41 5.4.2 Practice 42 5.5 STRING CONCATENATION 42 5.5.1 Demonstration 42 5.6 STRING FORMAT 43 5.6.1 Demonstration 43 5.6.2 Practice 45 5.7 USEFUL FUNCTIONS 46 5.7.1 Demonstration 46 5.7.2 Practice 48 5.8 INTERACT WITH GENAI 51 Chapter 6 ■ Case Studies of Python Fundamentals 52 6.1 SIMPLE CHECK OUT 52 6.2 TIPS SPLIT 53 6.3 COMPOUND INTEREST 54
📄 Page 11
x ■ Contents Section II Flow Control and Functions Chapter 7 ■ Branching 57 7.1 OPTIONAL BRANCHING 57 7.1.1 Demonstration 58 7.1.2 Practice 59 7.2 ALTERNATIVE BRANCHING 60 7.2.1 Demonstration 60 7.2.2 Practice 61 7.3 MULTIPLE BRANCHING 62 7.3.1 Demonstration 63 7.3.2 Practice 64 7.4 CASE STUDIES OF BRANCHING 66 7.4.1 What day is today? 66 7.4.2 Tax calculator 66 7.4.3 A simple calculator 67 7.4.4 Taxi fare calculator 68 7.5 INTERACT WITH GENAI 69 Chapter 8 ■ Repetition 70 8.1 CONDITION-BASED REPETITION 70 8.1.1 Explanation 70 8.1.2 Demonstration 71 8.1.3 Practice 72 8.2 COUNT-BASED REPETITION 74 8.2.1 Explanation 74 8.2.2 Demonstration 75 8.2.3 Practice 76 8.3 MAGIC CONTROL 78 8.3.1 Demonstration 78 8.3.2 Practice 79 8.4 CASE STUDIES OF REPETITION 80 8.4.1 Prime numbers 80 8.4.2 A simple grade book 80 8.4.3 Fahrenheit to Celsius converter 81 8.4.4 How many E and e are in a sentence? 82 8.5 INTERACT WITH GENAI 82
📄 Page 12
Contents ■ xi Chapter 9 ■ Functions 84 9.1 WHAT ARE FUNCTIONS? 84 9.1.1 Explanation 84 9.1.2 Example: Bread toaster 85 9.1.3 Practice 85 9.2 TYPES OF FUNCTIONS 86 9.2.1 Explanation 86 9.3 DEFINE A FUNCTION 86 9.3.1 Demonstration 86 9.3.2 Practice 87 9.4 PARAMETERS AND ARGUMENTS 89 9.4.1 Explanation 89 9.4.2 Demonstration 89 9.4.3 Practice 90 9.5 TWO PARAMETERS 92 9.5.1 Demonstration 93 9.5.2 Practice 93 9.6 HOW TO PASS ARGUMENTS 95 9.6.1 Demonstration 95 9.6.2 Practice 96 9.7 DEFAULT VALUE 96 9.7.1 Demonstration 96 9.7.2 Practice 97 9.8 RETURN VALUES 99 9.8.1 Explanation 99 9.8.2 Demonstration 99 9.9 RETURN NUMERIC VALUES 100 9.9.1 Demonstration 100 9.9.2 Practice 100 9.10 RETURN STR VALUES 102 9.10.1 Demonstration 102 9.10.2 Practice 102 9.11 RETURN BOOLEAN VALUES 102 9.11.1 Demonstration 103 9.11.2 Practice 103
📄 Page 13
xii ■ Contents 9.12 RETURN MULTIPLE VALUES 104 9.12.1 Demonstration 104 9.12.2 Practice 104 9.13 INTERACT WITH GENAI 106 Chapter 10 ■ Advanced Functions 107 10.1 NESTED FUNCTIONS 107 10.1.1 Explanation 107 10.1.2 Demonstration 107 10.1.3 Practice 108 10.2 HIERARCHICAL FUNCTIONS 110 10.2.1 Explanation 110 10.2.2 Demonstration 110 10.3 INTERACT WITH GENAI 112 10.4 RECURSIVE FUNCTIONS 112 10.4.1 Explanation 112 10.4.2 Demonstration 113 10.4.3 Practice 113 10.5 INTERACT WITH GENAI 115 Section III Data Structures Chapter 11 ■ List 119 11.1 WHAT IS A LIST 119 11.2 CREATE A LIST 120 11.2.1 Demonstration 120 11.2.2 Practice 121 11.3 HETEROGENEITY 122 11.3.1 Demonstration 122 11.3.2 Practice 123 11.3.3 Test your understanding 123 11.4 ACCESS A LIST BY INDEX 124 11.4.1 Demonstration 124 11.4.2 Practice 125 11.5 ACCESS A LIST BY ITERATION 126 11.5.1 Demonstration 126 11.5.2 Practice 127 11.6 LIST MANIPULATION 128
📄 Page 14
Contents ■ xiii 11.6.1 Demonstration 128 11.6.2 Practice 129 11.7 MORE MANIPULATION OF A LIST 130 11.7.1 Demonstration 130 11.7.2 Practice 131 11.8 SLICE A LIST 133 11.8.1 Demonstration 133 11.8.2 Practice 135 11.9 LIST COMPREHENSION 136 11.9.1 Demonstration 136 11.9.2 Practice 138 11.10 ADVANCED LIST COMPREHENSION 139 11.10.1 Demonstration 139 11.10.2 Practice 140 11.11 INTERACT WITH GENAI 142 11.12 EXPLORE MORE OF LIST 142 Chapter 12 ■ Tuple 143 12.1 WHAT IS A TUPLE 143 12.1.1 Explanation 143 12.2 CREATE A TUPLE 144 12.2.1 Demonstration 144 12.2.2 Practice 145 12.3 HETEROGENEOUS TUPLE IN PYTHON 146 12.3.1 Demonstration 146 12.3.2 Practice 147 12.4 ACCESS ELEMENTS IN A TUPLE BY INDEX 147 12.4.1 Demonstration 147 12.4.2 Practice 149 12.5 ACCESS ELEMENTS IN A TUPLE BY ITERATION 150 12.5.1 Demonstration 150 12.5.2 Practice 151 12.6 SLICE A TUPLE 152 12.6.1 Demonstration 152 12.6.2 Practice 153 12.7 TUPLE COMPREHENSION 154 12.7.1 Demonstration 154
📄 Page 15
xiv ■ Contents 12.7.2 Practice 155 12.8 INTERACT WITH GENAI 157 12.9 EXPLORE MORE OF TUPLE 157 Chapter 13 ■ Set 158 13.1 WHAT IS A SET 158 13.1.1 Explanation 158 13.1.2 Practice 158 13.2 CREATE A SET 159 13.2.1 Demonstration 159 13.2.2 Practice 160 13.3 ELEMENTS IN A SET 161 13.3.1 Demonstration 161 13.3.2 Practice 161 13.4 SET OPERATIONS 162 13.4.1 Demonstration 162 13.4.2 Practice 164 13.5 SET METHODS 165 13.5.1 Demonstration 165 13.5.2 Practice 166 13.6 SET COMPREHENSION 167 13.6.1 Demonstration 167 13.7 INTERACT WITH GENAI 168 13.8 EXPLORE MORE OF SET 169 Chapter 14 ■ Dictionary 170 14.1 WHAT IS A DICTIONARY 170 14.1.1 Explanation 170 14.1.2 Practice 171 14.2 CREATE A DICTIONARY 171 14.2.1 Demonstration 171 14.2.2 Practice 172 14.3 ACCESS A DICTIONARY 173 14.3.1 Demonstration 173 14.3.2 Practice 174 14.4 DICTIONARY METHODS 176 14.4.1 Demonstration 176
📄 Page 16
Contents ■ xv 14.4.2 Practice 177 14.5 DICTIONARY COMPREHENSION 178 14.5.1 Demonstration 178 14.5.2 Practice 179 14.6 INTERACT WITH GENAI 180 14.7 EXPLORE MORE OF DICTIONARY 180 Chapter 15 ■ Case Studies of Data Structures 181 15.1 WARM-UP 181 15.2 DATA CREATION 182 15.3 USING LISTS 182 15.4 USING TUPLES 184 15.5 USING SETS 185 15.6 USING DICTIONARIES 185 15.7 FURTHERMORE 187 15.8 COMPLEXITY 187 Section IV Data Collections Chapter 16 ■ Named Tuple 191 16.1 WHAT IS A NAMED TUPLE 191 16.1.1 Explanation 191 16.1.2 Demonstration 191 16.2 PACKAGE MANAGEMENT 192 16.3 CASE STUDY: CAR 193 16.4 INTERACT WITH GENAI 193 16.5 EXPLORE MORE OF NAMED TUPLE 194 Chapter 17 ■ Default Dictionary 195 17.1 WHAT IS A DEFAULT DICTIONARY 195 17.2 DEFAULT INT 197 17.2.1 Demonstration 197 17.2.2 Practice 197 17.3 DEFAULT LIST 198 17.3.1 Demonstration 198 17.3.2 Practice 199 17.4 DEFAULT SET 199 17.4.1 Demonstration 199
📄 Page 17
xvi ■ Contents 17.4.2 Practice 200 17.5 CASE STUDY: HACKATHON 200 17.6 INTERACT WITH GENAI 202 17.7 EXPLORE MORE OF DEFAULT DICTIONARY 202 Chapter 18 ■ Counters 203 18.1 WHAT IS A COUNTER 203 18.2 MORE ABOUT COUNTER 204 18.2.1 Explanation 204 18.2.2 Demonstration 204 18.2.3 Practice 205 18.3 CASE STUDY: ROMEO AND JULIET 206 18.4 INTERACT WITH GENAI 207 18.5 EXPLORE MORE OF COUNTER 207 What is Next? 209 Index 211
📄 Page 18
List of Figures 1.1 A script Python example. 4 1.2 An interactive Python example. 5 1.3 Jupyter notebook example. 7 3.1 Variable x refers to 5. 20 5.1 String non-negative index. 38 5.2 String negative index. 38 5.3 String slicing with step as 1. 40 5.4 String slicing with step as 2. 41 7.1 A flow chart for optional branching. 58 7.2 A flow chart for alternative branching. 60 7.3 A flow chart for multiple branching. 63 8.1 A flow chart for condition-based repetition. 71 8.2 A flow chart for count-based repetition. 74 9.1 A function as a box. 85 xvii
📄 Page 19
(This page has no text content)
📄 Page 20
List of Tables 3.1 Comparison of basic Python data types. 24 4.1 Truth table for logical operations and, or, and not. 32 4.2 Summary of Python operations. 34 5.1 Summary of Python string methods. 50 11.1 Summary of Python lists. 141 12.1 Summary of Python tuples. 156 13.1 Summary of Python sets. 168 14.1 Summary of Python dictionaries. 179 15.1 Summary of Python data structures. 181 15.2 Comparison of space and time complexities for Python data structures. (list, tuple, set, dictionary) 187 17.1 Summary of Python defaultdict with different default values. 202 xix
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List