Learning Python with Raspberry Pi

Learning Python with Raspberry Pi

Download

Introduction

COMPUTERS AREN’T JUST beige square things we use for work, they’re everything that has a programmable processing unit at its heart. Games consoles, smartphones, GPS units, tablets and a mind-boggling range of other devices all work in the same way. hey’re all computers, and they’ve taken over the world. They’re the things we use for work, for communications, and for relaxation. In fact, it’s hard to think of an area that hasn’t been taken over by computers.

Marketing people like to tell you that devices with embedded computers are smart (smartphones, smart TVs, smart watches, and so on), but the truth is they’re not. he processing units are just bits of silicon that follow a set of instructions. he “smart” in a smartphone doesn’t come from the computer chips, but from the people who program them.

Computers are the most powerful tools mankind has ever created, yet they’re under-utilised because few people know how to unleash their full potential. In a world where everything is a computer, the most important people are the programmers who can realise their full power. Programming, then, is an essential skill that’s only going to become more and more important in the future

What Is Programming? 
Computers, as we’ve said, aren’t smart. hey just follow a simple list of instructions one-by-one until they reach the end. hat list of instructions is a program. Programming, then, is the process of taking a task, splitting it up into steps, and writing it down in a language the computer can understand. he Raspberry Pi can understand many languages, but in this book, you’ll learn about Python 3. It’s a powerful language, and easy to learn. his book is for people who want to learn about computer programming and who have a Raspberry Pi. You don’t need any special skills or prior experience to work your way through this book, and it doesn’t matter if you’re not a classic geek who reads comics and watches Sci-Fi, and it doesn’t matter if you are. As long as you it those two basic criteria, this is the book is for you.

By the end of this book, you’ll have a good grasp of Python 3, and you’ll be familiar with many of the most useful modules (add-ons). Using these, you’ll be able to control almost every aspect of your Pi. You’ll make it interact with the world around through the General Purpose Inputs and Outputs (GPIOs), and communicate over the Internet. You’ll give it vision so it can snap photos and know what it’s looking at. You’ll make games and manipulate three-dimensional worlds. In short, this is a book about how to utilise your Raspberry Pi to its fullest potential

Why the.Raspberry Pi? 
There are a few things that make the Raspberry Pi a great device on which to learn programming. Firstly it’s cheap. At around a tenth of the price of a low-end PC, it’s cheap enough to have in addition to your main computer. his is useful because programmers tend to tinker with their development machine, and tinkering can break things. Generally this doesn’t damage the machine itself, but it can require you to reinstall the system, which can mean a bit of lost data, and it can put the machine out of action for a few hours. If you have a Pi that’s used just for development, this isn’t a problem; however, if your only computer is shared with a few other people, they may be a bit put out by this.

Secondly, the Pi is raw. It doesn’t come hidden away in a box, or in a complete system. his means that you get to decide what sort of system you want to make. You can enclose it in a case should you wish, or you can run it naked. You have access to GPIOs that many machines don’t have. Most computers come pre-packaged for a particular purpose (a tablet for surfing the web or playing games, a games console for watching movies or playing games, a laptop for working or playing games, and so on). A Raspberry Pi can turn its hand to any of these things with just a little technical know-how. thirdly, the Raspberry Pi runs Linux. his is an operating system a bit like Windows or Mac OS X. It provides a windowing system and a text-based interface for controlling the Pi. If you haven’t used Linux before, you’ll notice a few differences between it and the system you’re used to. For budding programmers, though, the most important difference is that Linux is far more flexible than the alternatives. Just as the physical design of the Raspberry Pi encourages experimentation, so does the operating system

How Does this Book Work?
Chapters 1–3 are all about getting started with Python on your Raspberry Pi. At the end of them, you’ll have a pretty good idea of what Python programming is about. he rest of the book is split into chapters that deal with different uses, such as games or multimedia. These chapters deal with diferent areas of Python, so generally, you don’t need to have read one chapter to understand the next (there are a couple of times where we refer back to something, but we make it clear what’s going on when we do).

This is means that you can go through this second part of the book in whatever order you want. For example, if you have a particular interest in multimedia, you can skip ahead to that, and then come back and read the others later.

Learning to program is all about actually getting your hands dirty and programming. his means that you can’t learn it by just sitting down and reading a book; you actually have to do some yourself. throughout this book we challenge you to put what you’ve learned to the test. Sometimes it’s through specific exercises designed to train your skills, other times it’s through taking the programs we’ve introduced and adding your own features to them. An important part of programming is the creativity to decide what you want the program to do, so you don’t have to follow our suggestions. In fact, we encourage you to treat our suggestions and code as a starting point to creating your own digital works of art.
Share This