The Raspberry Pi is a small, low-cost computer invented in the U.K. by the Raspberry Pi Foundation. It provides an easy-to-use tool for learning to program in Python. The Raspberry Pi, with its companion memory card, is preloaded with all the software you need to jump into programming in Python. The Raspberry Pi is made for you to learn to code by playing with it. It includes many input and output ports to give you flexibility in how you connect it. Much like a desktop computer, you need to connect a keyboard, mouse, monitor, and power cable to get started.
This book will teach you how to set up your Raspberry Pi, to write programs in Python, and to use your Raspberry Pi and Python to complete some projects. We’ll cover the basics of Python: displaying text, gathering input, repeating commands, creating logic, as well as using the input and output pins of your Raspberry Pi for projects.
This book does not cover advanced Python topics, nor act as a comprehensive reference for Python. Since it is a book for beginners, these topics have been left out for clarity and brevity. If you’d like to learn more Python, there are links to online resources throughout the book.
This book is for kids and other beginners who would like to learn to program. It’s also for kids who have a Raspberry Pi and want to learn what they can do with it. We’ll introduce you to your Raspberry Pi and teach you Python in a natural, playful way, introducing topics and giving you activities to do using your Raspberry Pi. You don’t need to have any prior programming experience. As long as you know how to use a mouse and open up programs by clicking on icons or menu items, you’ll do great.
This book requires a Raspberry Pi, cables, and some other parts to complete the projects and activities. These items are needed throughout the book:
To complete the projects in part 3, you’ll also need these parts:
You can typically find all these items in a Raspberry Pi starter kit or available individually through online retailers and stores that sell the Raspberry Pi, such as CanaKit, Sparkfun, or Adafruit.
This book is divided into three parts.
Part 1 introduces you to the Rasperry Pi, shows you how to set it up, and provides an introduction to the Python programming language:
Part 2 shows you how to build different text-based games while learning how to gather input, display information, make decisions, and repeat instructions in Python:
Part 3 involves making your Raspberry Pi interact with the world around it:
All source code in this book is in a fixed-width font like this, which sets it apart from the surrounding text. In many listings, the code is annotated to point out key concepts. I have tried to format the code so that it fits within the available page space in the book by adding line breaks and using indentation carefully.
The code accompanying this book is hosted at the GitHub repository: https://github.com/rheitz/hello-raspberry-pi. It is also available for download as a zip file from the publisher’s website at www.manning.com/books/hello-raspberry-pi.
Purchase of Hello Raspberry Pi! includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and other users. To access the forum and subscribe to it, point your web browser to www.manning.com/books/hello-raspberry-pi. This Author Online (AO) page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct on the forum.
Manning’s commitment to our readers is to provide a venue where a meaningful dialog among individual readers and between readers and the author can take place. It’s not a commitment to any specific amount of participation on the part of the author, whose contribution to the AO remains voluntary (and unpaid). We suggest you try asking the author some challenging questions, lest his interest stray!
The AO forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.
Ryan Heitz is a teacher, programmer, maker, father, and big kid. He is the cofounder of Ideaventions, a Science Center for kids, and Ideaventions Academy for Mathematics and Science, a private school focused on science and technology. He specializes in teaching kids how to experience computer science in a fun and engaging way. As a programmer, Ryan has developed software for everything from NASA data collection systems to web mapping applications.
18.222.120.133