
Python Crash Course
Eric Matthes
What's inside?
Dive into the world of programming with this hands-on guide to Python. Learn the basics, work on real projects, and gain the skills to become a proficient coder.
You'll learn
Key points
01The Gateway to Automation and Creation
Why do so many people give up on learning to code before they even write their first meaningful program? Often, the culprit is not the difficulty of the code itself, but the overwhelming frustration of setting up the environment and wading through dry, theoretical jargon. Eric Matthes understands this universal struggle perfectly. He begins the journey by completely demystifying the setup process, ensuring that you do not get bogged down in the tedious mechanics of installations and system paths. Python is chosen as the vehicle for this journey precisely because it is the closest programming language to plain English. It is a language designed to be read by humans just as much as it is executed by machines. By getting your environment running smoothly—whether you are on Windows, macOS, or Linux—you are granted immediate access to the playground of logic and creation. Once the technical hurdles are cleared, you are introduced to the absolute bedrock of all software: variables and simple data types. You can think of a variable not as a rigid box, but rather as a sticky note with a name written on it. When you create a variable, you are simply taking that sticky note and slapping it onto a piece of data. This mental model shifts how you view memory and data management. If you want to store a user’s name, you simply write something like first_name = "ada". The beauty of Python is that it does not force you to declare what kind of data you are storing beforehand; it is intelligent enough to figure it out dynamically. This frictionless experience allows you to focus on what you want to build rather than how you need to appease the computer. Text in Python is handled through strings, which are simply series of characters wrapped in quotes. But text is rarely perfect when it comes from a user. People type in lowercase, uppercase, and sometimes a chaotic mix of both. The book introduces you to methods, which are built-in actions you can perform on your data. By simply attaching .title() or .upper() to a string variable, you can instantly format a messy name into a beautifully capitalized title. You also learn the magic of f-strings, a feature that allows you to seamlessly weave variables directly into sentences without clunky concatenation. Instead of awkwardly adding strings together with plus signs, you just place an 'f' before the quotes and drop your variables into curly braces. It is a revelation that makes formatting text feel incredibly natural and intuitive. Numbers, of course, are the other side of the digital coin. You are guided through integers and floats, learning how Python handles basic arithmetic with the precision of a seasoned mathematician. Matthes is careful to point out the common pitfalls beginners face, such as the infamous type errors that occur when you try to mash a string and a number together. If you attempt to print a message saying you are 25 years old by directly combining text and the integer 25, Python will throw a fit because it does not know if you want to do math or display text. Learning to wrap that number in the str() function is your first real lesson in debugging—a core skill for any developer. Beyond the syntax, this opening chapter introduces you to the philosophy of the language itself. By typing import this into your terminal, you reveal the Zen of Python, a collection of guiding principles written by Tim Peters. Aphorisms like "Simple is better than complex" and "Readability counts" are not just catchy slogans; they are the architectural blueprints for writing good code. Matthes ingrains these principles into your mind early on. He teaches you that writing code is not just about making the machine work; it is about communicating your intentions clearly to the next human who reads it, which will very likely be your future self.
02Herding Cats with Lists and Tuples
As you grow more comfortable with individual variables, you quickly hit a conceptual wall. What happens when you need to keep track of a hundred usernames, a thousand high scores, or a continuously growing inventory of items in a game? Creating a separate, uniquely named variable for every single piece of information would be an absolute nightmare. This is where lists enter the stage, fundamentally changing the way you organize and manipulate data. A list in Python is exactly what it sounds like—a collection of items in a particular order. You can visualize a list as a long cargo train. The train itself is the list, and every boxcar attached to it holds a distinct piece of data. The most crucial adjustment you must make when learning about lists is understanding how computers count. In the human world, we start counting at one. In the Python world, counting begins at zero. The first element in your list is at index 0, the second is at index 1, and so on. This zero-based indexing trips up almost every beginner, but Matthes explains it with such clarity that it soon becomes second nature. Once you master how to access these elements, you are taught how to dynamically change the list. A program is rarely static. You will constantly need to add new elements using the append() method, which simply attaches a new boxcar to the end of the train. If you need to insert an item into a specific position, the insert() method easily slides it in, shifting everything else down. Removing items is just as flexible. Sometimes you know the exact position of the item you want to destroy, in which case the del statement acts as a precise sniper rifle. Other times, you want to remove an item but keep its value to use later—perhaps a player has died in a game, and you want to transfer their name to a "Game Over" screen. For this, the pop() method is your best friend. It plucks the last item off the list and hands it back to you for one final use. And if you only know the value of the item but not its location, the remove() method will hunt it down and delete it for you. This comprehensive toolkit gives you total mastery over your collections of data. Organization is just as important as storage. You are taught how to sort lists permanently using the sort() method, or temporarily using the sorted() function. The distinction between changing the actual underlying data versus just changing how it is displayed at the moment is a foundational concept in computer science. But managing data is only half the battle; the real power of programming comes from doing things to that data quickly. This introduces the for loop, arguably the most powerful engine of automation you will learn. A for loop allows you to tell Python, "Take every single item in this list, one by one, and perform this exact action on it." Whether you have five items or five million, the code remains exactly the same—just three or four lines of text. During this exploration of loops, you encounter Python's strict reliance on indentation. Unlike other languages that use chaotic brackets or semicolons to group code, Python uses whitespace. The spaces at the beginning of a line dictate the logical structure of your program. If you forget to indent a line inside a loop, Python will throw an error or logically misinterpret your commands. It forces you to write visually clean, structured code from the very beginning. Finally, the chapter introduces tuples, the immutable cousins of lists. While lists are designed to be changed, tuples are carved in stone. When you have a collection of values that must absolutely never be altered throughout the life of your program—like the dimensions of a game window—you wrap them in parentheses instead of square brackets, ensuring their permanent safety.

Continue reading with LeapAhead app
Full summary is waiting for you in the app
03The Logic of Choice and Connection
04The Magic of Never-Ending Tasks
05Packaging Your Logic for the Future
06Playing God with Object-Oriented Programming
07Conclusion
About Eric Matthes
Eric Matthes is a high school teacher living in Alaska who teaches Python programming. He has been writing programs since he was five years old and has a passion for making complex topics understandable and fun, particularly for beginners in the field of programming.