Python in examples
Dmitriy Kuptsov · Zenodo (CERN European Organization for Nuclear Research) · 2026
Python by Examples is an introductory textbook designed to help high school students and adult learners develop a foundational understanding of the Python programming language, data structures, and algorithms. The book combines essential mathematical concepts with practical programming examples to provide a structured introduction to algorithmic problem-solving. It begins with mathematical foundations, including number systems, functions, sequences and series, set theory, Boolean logic, probability, mathematical induction, recursion, and computational complexity. It then introduces the fundamental features of Python, covering variables, data types, operators, control flow, functions, classes, and operator overloading. Subsequent chapters explore fundamental data structures, including arrays, associative arrays, linked lists, stacks, queues, trees, heaps, and graphs. The final part examines core algorithmic techniques, such as divide and conquer, binary search, sorting algorithms, greedy algorithms, Huffman coding, Dijkstra’s shortest-path algorithm, and dynamic programming. Throughout the book, theoretical concepts are illustrated with Python code and worked examples, connecting mathematical reasoning with practical implementation. The book aims to equip readers with the knowledge and skills necessary to understand, analyze, and implement fundamental algorithms and to establish a solid foundation for further study in computer science and software development.