Welcome to the official code repository for Python: An Introduction to Code by Adam Roynon.
This 484-page guide is built on the principle of "Learning by Code." This repository contains all the examples, activity solutions, and extra challenges featured in the book.
Python: An Introduction to Code takes you on a journey from your first "Hello World" to the complex inner workings of computer science. It bridges the gap between basic scripting and professional software development.
- Foundations: Variables, Collection Types (Lists, Sets, Tuples, Dictionaries), and Logic.
- Systems: Exception Handling, File I/O, and Serialization.
- Object-Oriented Programming: Classes, Inheritance, and Method Resolution Order (MRO).
- GUI Development: Building visual desktop applications with Tkinter and Turtle.
- Computer Science Theory: A deep dive into Compilers vs. Interpreters, Memory Management (Heap vs. Stack), and Garbage Collection.
The final section of the book removes the "safety net." These projects provide Project Briefs—logic and functional requirements without the code—to simulate real-world development. This repository contains the reference solutions for:
♠️ Blackjack (21): A full game engine including Dealer AI behavior, "Bust" logic, and a bonus challenge to model a realistic, shuffled 52-card deck.- 🧮 Functional Calculator: A capstone project bridging the gap between back-end logic and GUI design using the Tkinter library.
- 🔐 Caesar Cipher: An introduction to cryptography. Build a tool to encrypt and decrypt messages using character-shifting and wrap-around logic.
- 🔄 Palindrome Checker: A test of string manipulation, slicing, and RegEx to identify phrases that read the same backwards and forwards.
- ✊ Rock Paper Scissors: A game that tracks state (wins/losses/draws) and uses the
randomlibrary for computer decision-making. - 🔢 Fibonacci Sequence: A mathematical challenge to calculate N numbers of the sequence using efficient loops.
You can access the code in two ways:
- Click the green "Code" button at the top of this page.
- Select "Download ZIP".
- Extract the folder to your computer. You now have all the Python files ready to open in your editor.
- Clone the repo:
git clone https://github.com/YOUR_USERNAME/python-introduction-by-code.git - Navigate to a chapter: e.g.,
cd chapter-22-oop - Run a script:
python 01-basic-class.py
Get the full 480+ page explanation: Buy the book on Amazon
