Chapter 1: Introduction

Hi there! We've never met, but it's a pleasure to meet you. My name is Scott, and I'm a programming enthusiast. I really like writing code, and I'm glad that you're interested as well. I'm guessing that you might have some background in programming, or perhaps it's a completely new concept for you. Either way, you must be curious about writing code. It is a pleasure to meet you under these circumstances.

If you've never used a programming language before, leaping into Python might seem a bit scary at first. You don't need to worry. Learning how to program a computer is far from impossible. Anyone can pick up the art of programming with a little time and a bit of patience. With practice, you'll have the ability to develop programs to play games, verify homework assignments, simulate real world situations, and do almost anything else you can imagine. Sure, it sounds lofty, and your first steps will be humble, but after a few sessions at the keyboard, you'll find out just how much power a programmer has.

This book deals with Python for good reasons. Python is a powerful language designed to easily develop simple programs. In Python, when you want to write a program to say hello to someone, you write a single line of code. In other languages, this simple task can involve a lot of additional overhead that can be unnecessarily confusing. Python's syntax helps new programmers understand the important concepts without resorting to details that can make a program hard to read.

Python is frequently used to teach elementary programming skills. Many of the more esoteric concepts in programming have been pushed aside so that the fundamental data structures can be understood with as little head-scratching as possible. It's also a great language for a wide range of tasks, and I'm convinced that it is the perfect way to get you programming quickly and confidently.

Who is this book for?

This book is designed to be used by novice programmers, and in particular by people who have no experience with programming whatsoever. We all have to start somewhere. The examples and teaching style used in this text make absolutely no expectations about your prior programming experience. You might be a professional looking to learn programming to help you with your job, you might be a student in school hoping to use programming to help with your homework or to build games, or you might be a curious kid hoping to get your computer doing some really cool stuff. Regardless of your age, you're probably new to programming, and that's great. This book has been written for you.

Most importantly, this book is for people who are excited about learning how to program! You should be curious about how computers do what they do, and you should be inspired enough to want to become someone who writes software to solve problems. It might sound silly to say this, but programming can be a lot of fun. It's rewarding to execute an idea on the computer that was previously just an idea in your head. I still remember the first time my chess program played its first move against me! You'll have your own exciting moments, and I hope that this book will help make them happen.

My goal with this book is to introduce programming in a clear and straightforward way, and to answer the questions you're likely to face along the way. Students often ask some very advanced questions, and I have a hard time saying no when the material is so interesting. It's always been unsatisfying for me to be told that I don't have enough experience yet to really understand what's going on when I ask a hard question. With that in mind, this book will introduce some advanced concepts in as clear a way as possible, and expand on them later in detail. I'll always try to avoid saying "just trust me," because you should always have the option to learn something you want to, even if the details are slightly more complicated than you have the background to fully grasp. You'll get there, and you should know these facilities exist, so I'm willing to let you play with something tricky if it helps you understand how a computer needs you to advise it how to act. In fact, we often learn the best lessons by breaking stuff! Fortunately, with programming, we're unlikely to break anything in a serious way, so we can take more chances and learn better lessons.

Breaking Stuff

What's the deal with being advised to break stuff anyway? That's not the type of thing that you're generally recommended to do. It's not even necessarily something that I go out of my way to apply when working.

However, when learning something new, I try to break things. In fact, I go out of my way to break stuff. When picking up a new concept like computer programming, you can actually increase your comfort level by figuring out the type of cases that are likely to break. You'll see what data can be used and where, and when you inevitably run into errors later (like everyone does), you won't be surprised.

There really isn't any risk to you or to your computer by breaking your program code either. You never need to worry about formatting your hard drive by trying to multiply a string and a negative number, and you won't set a fire by forgetting a symbol in your math equations. You should feel comfortable knowing that a big wall of red text indicating an error is just another opportunity to learn.

The idea that breaking things can actually help you become a better programmer is a central idea in this book, and I hope that you take full advantage. I've broken a lot of code in my day, whether intentionally or not, and I think that it's given me the knowledge to help teach other people how to write good code.

Summary

Programming is a creative process, and you can learn some of the most important things by experimenting. Breaking code and causing errors are great ways to deeply understand how things work. Once you've built up the foundations you need to understand what a program is and why it's structured in a certain way, you'll be well on your way to writing your own code. This book will start with some very basic examples. It's important that you remember that we're starting small on purpose. By the end of the book, we'll be developing some real code that tackles larger problems, giving you a roadmap for developing your own big projects. You're always encouraged to modify the examples in the text, to change names and orderings, and especially to break things to see exactly what the code does.

Best of luck, and I hope you enjoy the journey!