Math and Python

By | May 27, 2026

You can learn mathematics and Python (programming) simultaneously on Colab.Curiosity about mathmatics, the foundation of everything the AI era.

You can download the book-linked learning files for use with Colab from here.

Download file: ( Math and Python Stage 1. Chapter1~13 )

CONTENTS
Chapter 1: Getting started with Python 8
Introduction 9
Before we start ~ Using Google Colab ~ 10
1.1 What is Python 13
1.2 Variables 17
1.3 Operators 23
1.4 print and input (show and receive) 28
■ Chapter 1 Summary 35
■ End-of-chapter exercises 36
■ Answers and explanations 36
Chapter 2: If…then (conditionals) 39
Introduction ~ Programs that make decisions ~ 40
2.1 The basics of if 41
2.2 Multiple conditions (elif) 46
2.3 Conditions with logical operators 49
2.4 Real practice: making real programs 52
■ Chapter 2 Summary 57
■ End-of-chapter exercises 58
■ Answers and explanations 59
Chapter 3: Loops 61
Introduction ~ The power of repetition ~ 62
3.1 The basics of for 63
3.2 while loops (loop with a condition) 68
3.3 break and continue (controlling loops) 73
3.4 Nested loops (a loop inside a loop) 76
3.5 Practice: Number-guessing game 80
■ Chapter 3 Summary 84
■ End-of-chapter exercises 85
■ Answers and explanations 86
Chapter 4: Handling lots of data 88
Introduction ~ Bundling lots of data together ~ 89
4.1 The basics of lists 89
4.2 Lists with loops 94
4.3 Strings are sequences too 99
4.4 Dictionaries (dict) 104
4.5 Practical: Grade management program 109
■ Chapter 4 Summary 113
■ End-of-chapter exercises 114
■ Answers and explanations 115
Chapter 5: Make your own commands (functions) 118
Introduction ~ Making your own commands ~ 119
5.1 The basics of functions 120
5.2 Arguments and return values 124
5.3 Three benefits of functions 129
5.4 Scope: where variables are visible 133
5.5 Practice: Calculator and statistics functions 138
■ Chapter 5 Summary 142
■ End-of-chapter exercises 144
■ Answers and explanations 145
Chapter 6: Useful toolboxes (modules) 148
Introduction ~ Python module library ~ 149
6.1 What is a module? 150
6.2 random module: controlling chance 153
6.3 math module: your math companion 156
6.4 datetime module: working with time 160
6.5 Practice: Part 1 finale program 163
■ Chapter 6 + Part 1 Summary 167
■ End-of-chapter exercises 169
■ Answers and explanations 170
Chapter 7: Numbers and Calculation 173
Welcome to Part 2 ~ Math meets Python ~ 174
7.1 The world of integers: divisors, multiples, primes 175
7.2 Prime factorization 180
7.3 Greatest common divisor and least common multiple 185
7.4 Square roots 190
7.5 Absolute value and exponent rules 196
■ Chapter 7 Summary 200
■ End-of-chapter exercises 201
■ Answers and explanations 202
Chapter 8: Solving Equations 205
Introduction ~ Equations: a game to find x ~ 206
8.1 Linear equations: find x by moving terms 207
8.2 Simultaneous equations: substitution 212
8.3 Simultaneous equations: elimination 216
8.4 Inequalities: watch the sign direction 220
8.5 Binary search: a Python way to solve equations 225
■ Chapter 8 Summary 231
■ End-of-chapter exercises 231
■ Answers and explanations 234
Chapter 9: Functions and Graphs 238
Introduction ~ Turn equations into pictures ~ 239
9.1 The coordinate plane and points 240
9.2 Linear function y = ax + b 245
9.3 Direct and inverse proportion 251
9.4 The parabola of y = ax^2 256
9.5 Solve equations using graphs 260
■ Chapter 9 Summary 266
■ End-of-chapter exercises 267
■ Answers and explanations 268
Chapter 10: Geometry and Measurement 271
Introduction ~ Describe shapes with numbers ~ 272
10.1 Triangle area: base x height / 2 273
10.2 Circles: circumference and area 277
10.3 The Pythagorean theorem 282
10.4 Polygons and the sum of interior angles 288
10.5 Volumes of 3D shapes 293
■ Chapter 10 Summary 298
■ End-of-chapter exercises 298
■ Answers and explanations 300
Chapter 11: Probability and Statistics 304
Introduction ~ Read the world through data ~ 305
11.1 Basic probability 306
11.2 Counting: permutations and combinations 312
11.3 Measures of center: mean, median, mode 317
11.4 Spread of data: variance and standard deviation 322
11.5 Data visualization: histogram and box plot 327
■ Chapter 11 Summary 332
■ End-of-chapter exercises 333
■ Answers and explanations 334
Chapter 12: Sequences 337
Introduction ~ The power of finding patterns ~ 338
12.1 Sequence basics: finding the pattern 339
12.2 Arithmetic sequences: adding a fixed number 344
12.3 Geometric sequences: the world of doubling 349
12.4 The Fibonacci sequence and the golden ratio 356
12.5 Recurrences and the Collatz conjecture 363
■ Chapter 12 Summary 369
■ End-of-chapter exercises 370
■ Answers and explanations 372
Chapter 13: Final Review 375
13.0 Introduction ~ Turn knowledge into skill ~ 376
13.1 Project 1: Board game win rate analysis 378
13.2 Project 2: Draw fractal shapes 383
13.3 Project 3: Budget simulator 388
13.4 Free research guide: pick your own topic 393
13.5 Closing ~ To you, living in the AI era ~ 397