CHF65.90
Download est disponible immédiatement
Augment your knowledge of Python with this entertaining learning guide, which features 100 exercises and programming puzzles and solutions. Python Challenges will help prepare you for your next exam or a job interview, and covers numerous practical topics such as strings, data structures, recursion, arrays, and more.
Each topic is addressed in its own separate chapter, starting with an introduction to the basics and followed by 10 to 15 exercises of various degrees of difficulty, helping you to improve your programming skills effectively. Detailed sample solutions, including the algorithms used for all tasks, are included to maximize your understanding of each area. Author Michael Inden also describes alternative solutions and analyzes possible pitfalls and typical errors.
Three appendices round out the book: the first covers the Python command line interpreter, which is often helpful for trying out the code snippets and examples in the book, followed by an overview of Pytest for unit testing and checking the solutions. The last explains the O notation for estimating performance.
After reading this book, you'll be prepared to take the next step in your career or tackle your next personal project. All source code is freely available for download via the Apress website.
You will:
Auteur
Michael Inden is an Oracle-certified Java developer with over 20 years of professional experience designing complex software systems for international companies. There, he has worked in various roles such as SW developer, SW architect, consultant, team leader, CTO, head of academy, and trainer. Currently, he is working as a freelancer. His special interests are creating high-quality applications with ergonomic GUIs, developing and solving programming puzzles, and coaching. He likes to pass on his knowledge and has led various courses and talks, both internally and externally, as well as at conferences such as JAX/W-JAX, JAX London, and Oracle Code One. Besides, he is also an author of technical books. His german books, among others "Der Weg zum Java-Profi", Java Challenge", "Python Challenge" are all published by dpunkt.verlag.
Contenu
1 Einleitung . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1 Aufbau der Kapitel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Grundgerüst des PyCharm-Projekts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Grundgerüst für die Unit Tests mit PyTest . . . . . . . . . . . . . . . . . . . . . . . . 41.4 Anmerkung zum Programmierstil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.5 Anmerkung zu den Aufgaben . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.6 Ausprobieren der Beispiele und Lösungen . . . . . . . . . . . . . . . . . . . . . . . 9I Grundlagen 112 Mathematische Aufgaben . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.1 Einführung . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.1.1 Römische Zahlen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.1.2 Zahlenspielereien . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.2 Aufgaben . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.1 Aufgabe 1: Grundrechenarten ( ) . . . . . . . . . . . . . . . . . 212.2.2 Aufgabe 2: Zahl als Text ( ) . . . . . . . . . . . . . . . . . . . . . . 222.2.3 Aufgabe 3: Vollkommene Zahlen ( ) . . . . . . . . . . . . . . . 222.2.4 Aufgabe 4: Primzahlen ( ) . . . . . . . . . . . . . . . . . . . . . . . 232.2.5 Aufgabe 5: Primzahlpaare ( ). . . . . . . . . . . . . . . . . . . . . 232.2.6 Aufgabe 6: Prüfsumme ( ) . . . . . . . . . . . . . . . . . . . . . . . 232.2.7 Aufgabe 7: Römische Zahlen ( ) . . . . . . . . . . . . . . . . . . 242.2.8 Aufgabe 8: Kombinatorik ( ) . . . . . . . . . . . . . . . . . . . . . . 242.2.9 Aufgabe 9: Armstrong-Zahlen ( ) . . . . . . . . . . . . . . . . . 252.2.10 Aufgabe 10: Max Change Calculator ( ) . . . . . . . . . . . 252.2.11 Aufgabe 11: Befreundete Zahlen ( ) . . . . . . . . . . . . . . . 262.2.12 Aufgabe 12: Primfaktorzerlegung ( ) . . . . . . . . . . . . . . 262.3 Lösungen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.3.1 Lösung 1: Grundrechenarten ( ) . . . . . . . . . . . . . . . . . . 272.3.2 Lösung 2: Zahl als Text ( ) . . . . . . . . . . . . . . . . . . . . . . . 292.3.3 Lösung 3: Vollkommene Zahlen ( ) . . . . . . . . . . . . . . . . 312.3.4 Lösung 4: Primzahlen ( ) . . . . . . . . . . . . . . . . . . . . . . . . 33viii Inhaltsverzeichnis2.3.5 Lösung 5: Primzahlpaare ( ) . . . . . . . . . . . . . . . . . . . . . 352.3.6 Lösung 6: Prüfsumme ( ) . . . . . . . . . . . . . . . . . . . . . . . . 392.3.7 Lösung 7: Römische Zahlen ( ) . . . . . . . . . . . . . . . . . . . 402.3.8 Lösung 8: Kombinatorik ( ) . . . . . . . . . . . . . . . . . . . . . . . 432.3.9 Lösung 9: Armstrong-Zahlen ( ) . . . . . . . . . . . . . . . . . . 462.3.10 Lösung 10: Max Change Calculator ( ) . . . . . . . . . . . . 492.3.11 Lösung 11: Befreundete Zahlen ( ) . . . . . . . . . . . . . . . . 502.3.12 Lösung 12: Primfaktorzerlegung ( ) . . . . . . . . . . . . . . . 523 Rekursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553.1 Einführung . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553.1.1 Mathematische Beispiele . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553.1.2 Algorithmische Beispiele . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593.1.3 Typische Probleme: Endlose Aufrufe und RecursionError 643.2 Aufgaben . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663.2.1 Aufgabe 1: Fibonacci ( ) . . . . . . . . . . . . . . . . . . . . . . . . . 663.2.2 Aufgabe 2: Ziffern verarbeiten ( ) . . . . . . . . . . . . . . . . . 663.2.3 Aufgabe 3: ggT / GCD ( ) . . . . . . . . . . . . . . . . . . . . . . . . 673.2.4 Aufgabe 4: Reverse String ( ) . . . . . . . . . . . . . . . . . . . . 683.2.5 Aufgabe 5: Array Sum ( ) . . . . . . . . . . . . . . . . . . . . . . . . 683.2.6 Aufgabe 6: Array Min ( ) . . . . . . . . . . . . . . . . . . . . . . . . . 683.2.7 Aufgabe 7: Konvertierungen ( ) . . . . . . . . . . . . . . . . . . . 693.2.8 Aufgabe 8: Exponentialfunktion ( ) . . . . . . . . . . . . . . . . 703.2.9 Aufgabe 9: Pascal'sches Dreieck ( ) . . . . . . . . . . . . . . . 713.2.10 Aufgabe 10: Zahlenpalindrome ( ) . . . . . . . . . . . . . . . . 713.2.11 Aufgabe 11: Permutationen ( ) . . . . . . . . . . . . . . . . . . . 723.2.12 Aufgabe 12: Count Substrings ( ) . . . . . . . . . . . . . . . . . 723.2.13 Aufgabe 13: Lineal ( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . 733.3 Lösungen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743.3.1 Lösung 1: Fibonacci ( ) . . . . . . . . . . . . . . . . . . . . . . . . . . 743.3.2 Lösung 2: Ziffern verarbeiten ( ) . . . . . . . . . . . . . . . . . . 763.3.3 Lösung 3: ggT / GCD ( ) . . . . . . . . . . . . . . . . . . . . . . . . . 783.3.4 Lösung 4: Reverse String ( ) . . . . . . . . . . . . . . . . . . . . . 803.3.5 Lösung 5: Array Sum ( ) . . . . . . . . . . . . . . . . . . . . . . . . . 813.3.6 Lösung 6: Array Min ( ) . . . . . . . . . . . . . . . …