Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 GitHub - Gagniuc/Python-Coding-Examples-from-Simple-to-Complex: This book takes the reader from Python basics to advanced applications through 227 worked examples, covering variables, arrays, control flow, functions, recursion, objects, JSON, sorting, statistics, signal analysis, logic gates, randomness, Markov chains, and Python-specific tools such as file I/O and GUIs.
Nothing Special   »   [go: up one dir, main page]

Skip to content

This book takes the reader from Python basics to advanced applications through 227 worked examples, covering variables, arrays, control flow, functions, recursion, objects, JSON, sorting, statistics, signal analysis, logic gates, randomness, Markov chains, and Python-specific tools such as file I/O and GUIs.

License

Notifications You must be signed in to change notification settings

Gagniuc/Python-Coding-Examples-from-Simple-to-Complex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Coding Examples from Simple to Complex

This book offers a structured journey through the foundations and applications of programming in Python, progressing from simple constructs to advanced examples. It begins with an introduction to Python’s role in the future of computing and the advantages of working with native features, before moving on to the essentials of variables, assignments, and basic operations. Conditional branching and loop structures are explored in detail, showing not only their syntax but also their logical role in algorithm design. Arrays and lists are presented as dynamically resizable structures, leading naturally into the traversal and manipulation of multidimensional data. A dedicated section on matrix operations expands these ideas toward higher-level mathematical and algorithmic tasks. The book then addresses the creation and use of functions, including recursion and composition, and transitions into object-oriented concepts and JSON data structures. Moderate examples build on this knowledge with sorting, permutations, statistics, and various conversions, preparing the ground for complex applications such as signal analysis, logic gate simulations, and island detection in matrices. The final chapters highlight randomness, Markov chains, and Python-specific utilities like file I/O, GUIs, and HTTP requests. With 227 worked examples, the text illustrates how simple ideas evolve into complex solutions, providing both conceptual clarity and practical guidance for learners and practitioners alike.

Note: The repositories below showcase a few demo algorithmic implementations drawn from the total of 227 algorithms presented in Coding Examples from Simple to Complex - Applications in Python. Synthesis Lectures on Computer Science (Springer International Publishing, 2024). You may find these standalone implementations insightful:


Table of Contents (Python)

1. Introduction

  • 1.1 Future of Python
  • 1.2 The content is native

2. Variables

  • Ex. (1) – Commenting inside code
  • Ex. (2) – Naming variables
  • Ex. (3) – Write your first Python program
  • Ex. (4) – The meaning of "a = b"
  • Ex. (5) – Assign and reassign with type change
  • Ex. (6) – Basic mathematical operations
  • Ex. (7) – The meaning of modulo operator
  • Ex. (8) – The meaning of "a = a + 1"
  • Ex. (9) – The aggregate assignment
  • Ex. (10) – The plus operator
  • Ex. (11) – The minus operator
  • Ex. (12) – Variable playground
  • Ex. (13) – Swap values
  • Ex. (14) – Empty a variable
  • Ex. (15) – Line continuation
  • Ex. (16) – Formatted output

3. Conditional Branching

  • Ex. (17) – If then else – conditional statements (I)
  • Ex. (18) – If then else – conditional statements (II)
  • Ex. (19) – If then else - conditional statements (III)
  • Ex. (20) – If then elseif else - conditional statements
  • Ex. (21) – Simulation of the Switch statement

4. Loops

  • Ex. (22) – While loop
  • Ex. (23) – Do while
  • Ex. (24) – Simple for loop
  • Ex. (25) – Reverse by subtraction from the upper limit
  • Ex. (26) – Reverse for-loop
  • Ex. (27) – The meaning of before and after
  • Ex. (28) – Reverse by subtraction from the upper limit variable
  • Ex. (29) – For loop summation
  • Ex. (30) – Simple counter summation
  • Ex. (31) – Sum all results of addition of 1 in a n×n cycle
  • Ex. (32) – Sum all results of addition of 3 in a n×n cycle
  • Ex. (33) – Sum all results of the multiplication between i and j
  • Ex. (34) – Nested for loops and summation of counter variables
  • Ex. (35) – Nested for loops and summation based on the inner counter
  • Ex. (36) – Nested for loops & summation based on counters and upper limits (I)
  • Ex. (37) – Nested for loops & summation based on counters and upper limits (II)
  • Ex. (38) – Nested for loops & summation based on counters and upper limits (III)
  • Ex. (39) – Show i and j coordinates at each step
  • Ex. (40) – One for loop that simulates two for loops

5. Dynamically Resizable Arrays (lists)

  • Ex. (41) – Array addition
  • Ex. (42) – Extracting individual values from the elements of an array
  • Ex. (43) – Adding elements
  • Ex. (44) – Using array literals of different data type
  • Ex. (45) – Accessing array elements
  • Ex. (46) – Changing values in array elements - swap values or replace
  • Ex. (47) – Extracting individual values from the elements of an array
  • Ex. (48) – Array length
  • Ex. (49) – Accessing the values from the components of an array
  • Ex. (50) – Traverse a 1D array using a while loop (I)
  • Ex. (51) – Traverse a 1D array using a while loop (II)
  • Ex. (52) – Traverse a 1D array using a for loop
  • Ex. (53) – The for a in b
  • Ex. (54) – Print all integers from array using a for loop
  • Ex. (55) – Sum all values from array
  • Ex. (56) – Multiplication involving a scalar and a 1D array
  • Ex. (57) – Insert values into an array
  • Ex. (58) – Insert ascending and descending integer values into arrays
  • Ex. (59) – Add forward and reverse values and subtract max
  • Ex. (60) – Pointless equilibrium
  • Ex. (61) – Max value from array
  • Ex. (62) – Min value from array
  • Ex. (63) – Max value above two arrays of the same size
  • Ex. (64) – Max value above two arrays of different sizes
  • Ex. (65) – Which is bigger between n and n + 1?
  • Ex. (66) – Which is bigger between n and n + 1? (optimization)
  • Ex. (67) – Sum two arrays
  • Ex. (68) – Simple array mapping
  • Ex. (69) – Sum by coordinates (I)
  • Ex. (70) – Sum by coordinates (II)
  • Ex. (71) – Cutoff value
  • Ex. (72) – Swap array elements by pattern
  • Ex. (73) – Mix array based on pattern
  • Ex. (74) – Swap array values
  • Ex. (75) – Intermittent value swap
  • Ex. (76) – Reverse string
  • Ex. (77) – The welding of array values
  • Ex. (78) – Static modulo - fill up array with modulo results
  • Ex. (79) – Dynamic modulo - take a[i] modulo j
  • Ex. (80) – Convert a string to an array
  • Ex. (81) – The rule of three simples
  • Ex. (82) – Average, standard deviation and coefficient of variation
  • Ex. (83) – Horizontal chart from ASCII characters
  • Ex. (84) – Horizontal chart with bars proportional with max from array
  • Ex. (85) – Horizontal chart with UTF characters proportional with max array

6. Traversal of Multidimensional Arrays

  • Ex. (86) – Accessing the elements of matrix A
  • Ex. (87) – Accessing the elements of matrix A using nested for loops
  • Ex. (88) – Traverse a matrix with a single for loop (I)
  • Ex. (89) – Traverse a matrix with a single for loop (II)
  • Ex. (90) – Accessing the elements of a 3D array
  • Ex. (91) – Traverse a 3D object with a single for loop
  • Ex. (92) – Traverse a 2D object with a single for loop and integer division
  • Ex. (93) – Traverse a 2D object with a single for loop using arithmetic operators
  • Ex. (94) – 3D traversal with one for-loop using only arithmetic operators

7. Matrix Operations

  • Ex. (95) – How many 1's in matrix
  • Ex. (96) – Sum all values from matrix elements
  • Ex. (97) – Show matrix content
  • Ex. (98) – Multiplication involving a scalar and a matrix
  • Ex. (99) – Sum all values from the rows of the matrix
  • Ex. (100) – Sum all values from the columns of the matrix
  • Ex. (101) – Find max and min on columns and rows of a matrix
  • Ex. (102) – Multiply all values from the columns/rows and store them in array
  • Ex. (103) – Sum all values from the right diagonal of the square matrix
  • Ex. (104) – Sum all values from the left diagonal of the square matrix
  • Ex. (105) – Sum all values from the left and right diagonal of a square matrix
  • Ex. (106) – Sum all values from the left and right diagonal by using conditions
  • Ex. (107) – Show bottom–left part of the matrix
  • Ex. (108) – Show bottom–left part of the matrix and flip horizontal
  • Ex. (109) – Show top–right part of the matrix
  • Ex. (110) – Show top–right part of the matrix and flip 90 degrees left
  • Ex. (111) – Show top–right, flip 90 degrees left and flip horizontally
  • Ex. (112) – Secondary diagonal scan (right)
  • Ex. (113) – Secondary diagonal scan (left)
  • Ex. (114) – Show bottom–right and flip horizontally
  • Ex. (115) – Matrix flip vertical
  • Ex. (116) – Matrix flip horizontal
  • Ex. (117) – Sum values from elements of a matrix based on a map
  • Ex. (118) – Add two matrices into a third
  • Ex. (119) – Matrix multiplication with three for loops
  • Ex. (120) – Matrix multiplication with two for loops
  • Ex. (121) – Multiply specific elements of two matrices based on a map
  • Ex. (122) – Different operations based on maps
  • Ex. (123) – Different operations based on maps (SMC)
  • Ex. (124) – Nested arrays

8. Functions

8.1 Built-in Functions/Methods

  • Ex. (125) – Built-in sin, exp
  • Ex. (126) – Max between two integer variables
  • Ex. (127) – Max between two specific elements of an array
  • Ex. (128) – Max over the values from an array
  • Ex. (129) – Max over two array variables
  • Ex. (130) – Random integers from 0 to 99 in an array
  • Ex. (131) – Insert random values in the elements of a matrix
  • Ex. (132) – Split string to integers by using a delimiter symbol
  • Ex. (133) – Split string to array by using the "|" symbol
  • Ex. (134) – Cascading built-in functions (split, join, length)
  • Ex. (135) – Built-in sort function

8.2 Making of Functions

  • Ex. (136) – Making of a function
  • Ex. (137) – Making of a function with more than one parameter
  • Ex. (138) – Gauss summation - sum all from 0 to n
  • Ex. (139) – Function calls to other functions
  • Ex. (140) – A simple scanner to find the output distribution
  • Ex. (141) – Function chaining - nested function calls
  • Ex. (142) – Function composition
  • Ex. (143) – Global variables and constants
  • Ex. (144) – Pure and impure functions
  • Ex. (145) – Procedures vs Functions

8.3 Recursion

  • Ex. (146) – Replacement for repeat loops with recursion
  • Ex. (147) – Repeat string n times recursively
  • Ex. (148) – Sum from 0 to n recursively
  • Ex. (149) – Factorial from 0 to n
  • Ex. (150) – Generate a sequence recursively
  • Ex. (151) – Generate fibonacci recursively
  • Ex. (152) – Sum all from array recursively

9. Objects

9.1 Constructors And Methods

  • Ex. (153) – Using an object constructor
  • Ex. (154) – An object with three properties and a method (I)
  • Ex. (155) – An object with three properties and a method (II)
  • Ex. (156) – An object with complex methods
  • Ex. (157) – Generate multiple objects with methods

9.2 JSON

  • Ex. (158) – Object to JSON
  • Ex. (159) – JSON to Object
  • Ex. (160) – Anything to object to string
  • Ex. (161) – Complex string to object (I) - direct nested access
  • Ex. (162) – Complex string to object (II) - nested access by reference
  • Ex. (163) – Make 1D array from parts of an object
  • Ex. (164) – Make a matrix from parts of an object

10. Moderate Examples

10.1 Load Arrays from Strings

  • Ex. (165) – Strings to 1D arrays (I)
  • Ex. (166) – Strings to 1D arrays (II)
  • Ex. (167) – A 2D array loaded from string
  • Ex. (168) – Load a matrix from a string by using two delimiters
  • Ex. (169) – A function to correctly display a matrix
  • Ex. (170) – A function to load and display matrices
  • Ex. (171) – Load two matrices from strings and make the addition

10.2 Some Matrix Operations

  • Ex. (172) – Function to swap diagonal of matrix
  • Ex. (173) – Function to transpose a matrix
  • Ex. (174) – Function for rotation of a matrix by 90 degrees

10.3 Logical Operations

  • Ex. (175) – Logical NOT
  • Ex. (176) – Logical AND
  • Ex. (177) – Logical OR
  • Ex. (178) – Logical NAND (NOT AND)
  • Ex. (179) – Logical NOR (NOT OR)
  • Ex. (180) – Logical XOR
  • Ex. (181) – Logical XNOR

10.4 Miscellaneous

  • Ex. (182) – Logarithm of b in base a
  • Ex. (183) – Smooth signal
  • Ex. (184) – Greatest common divisor (GCD)
  • Ex. (185) – Pseudo random generator
  • Ex. (186) – Double brute force algorithm (DBFA)
  • Ex. (187) – Alphabet detection
  • Ex. (188) – Alphabet detection on matrices

10.5 Sorting

10.6 Permutations

  • Ex. (192) – Get all permutations of a given string (I)
  • Ex. (193) – Get all permutations of a given string (II)

10.7 Statistics

10.8 Useful Conversions

  • Ex. (200) – Text (txt) to hexadecimal (hex)
  • Ex. (201) – A txt to hex from array a to array b
  • Ex. (202) – A txt to hex with in-place replacement
  • Ex. (203) – A txt to hex in a function that receives an as argument
  • Ex. (204) – Multiple functions for any to any conversion
  • Ex. (205) – One function for any to any conversion and input type detection
  • Ex. (206) – Base64 encoding function

11. Complex Examples

12. Randomness and Programming

  • Ex. (215) – Get complementary array by using random values
  • Ex. (216) – Take the first 20% of the closest solutions (mutation/selection)
  • Ex. (217) – Find complementary matrix by using stochastic means
  • Ex. (218) – A two states Markov Chain simulator based on letters
  • Ex. (219) – A two states Markov Chain simulator based on probability values
  • Ex. (220) – Multiply a probability vector with a probability matrix n times
  • Ex. (221) – A Markov Chain framework for simulation

13. Python Specific

  • Ex. (222) – Base64 encoding and decoding via built-in functions
  • Ex. (223) – Local storage
  • Ex. (224) – File I/O
  • Ex. (225) – Charts
  • Ex. (226) – The Graphical User Interface (GUI)
  • Ex. (227) – HTTP requests

References


Paul A. Gagniuc. Coding Examples from Simple to Complex - Applications in Python. Synthesis Lectures on Computer Science. Springer International Publishing, 2024, pp. 1-245.


Coding Examples from Simple to Complex

About

This book takes the reader from Python basics to advanced applications through 227 worked examples, covering variables, arrays, control flow, functions, recursion, objects, JSON, sorting, statistics, signal analysis, logic gates, randomness, Markov chains, and Python-specific tools such as file I/O and GUIs.

Topics

Resources

License

Stars

Watchers

Forks

0