Hello Raspberry Pi!: Python programming for kids and other beginners
Ryan Heitz
Copyright
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact:
Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email:
orders@manning.com2016 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without elemental chlorine.
| Manning Publications Co.20 Baldwin RoadPO Box 761Shelter Island, NY 11964 | Development editor: Dan MaharryCopyeditor: Tiffany TaylorProofreader: Alyson BrenerTechnical proofreader: Romin IraniTypesetter: Marija TudorCover designer: Leslie Haimes |
ISBN: 9781617292453
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 MAL 18 17 16 15 14 13
Dedication
To Juliana, Daniel, and John
Brief Table of Contents
Table of Contents
Preface
In 2013, a parent and friend of mine asked if I would teach a Python course to middle school students at a local school. My friend gently asked if I could somehow use the Raspberry Pi computer in the course. I love learning new things and I had been reading a lot about the Raspberry Pi. So as you can imagine, I was tremendously excited at the opportunity of using it and emphatically said Yes! That event began my journey of developing a course for kids on programming in Python and using the Raspberry Pi and later, this book.
Quickly, as I worked with the Raspberry Pi, I became a disciple of the Raspberry Pi inventors: the best way for kids to learn programming is by giving them an affordable, ready-to-program computer. It was the perfect platform to learn how to program.
As a teacher of computer science, I grew to deeply appreciate Python. I became convinced that it was not only a great programming language, but its focus on readability and simplicity made it perfect for kids to learn as their first programming language.
Fast forward in timeafter teaching Python using the Raspberry Pi to many classes of kids, I had developed a set of engaging and funny projects that the kids enjoyed. Just as important, the students learned! The feedback from the kids and the parents was fantastic! Imagine kids rushing to take part in a programming class. It was wonderful!
A few months after developing my course, Nicole Butterfield and Robin de Jongh of Manning Publications contacted me about turning it into a book. I was thrilled at the prospect of bringing the activities and projects from the computer lab into the hands of kids everywhere. What is more, this book would fill an important gap. What I had found when I originally started teaching my course was that there were no books on the Raspberry Pi and programming in Python that were designed for kids. Since the main reason for inventing the Raspberry Pi was to get more kids programming, I was enthusiastic to work on this project.
Nearly two years later, and several versions of the Raspberry Pi later, Im proud to present this book to the kids and other beginners who want to learn to program. I hope you enjoy using this book and it starts you on your own journey in computer science!
Acknowledgments
Thank you to my wife, Juliana, and our two children, Daniel and John, for their endless support and patience through the long days, nights, and weekends I needed to write this book.
Id also like to thank Manning Publications for having the vision to pursue this project. In particular, thanks to Robin de Jongh and Nicole Butterfield who kicked off this project by finding and encouraging me; to publisher Marjan Bace for his commitment to me and to this book; to Ozren Harlovic for orchestrating the book review process; to Kevin Sullivan and Mary Piergies for overseeing production; to Chuck Larson for the wonderful work on the graphics; to Tiffany Taylor for her outstanding copyediting; to Alyson Brener for her thorough proofreading; to Candace Gillhoolley and Ana Romac for promoting the book; to technical development editors Donald Bailey, Joel Kotarski, Jeanne Boyarsky, and John Hyaduck; and to Romin Irani, technical proofreader.
This book was significantly improved by my editor at Manning, Dan Maharry, who helped to develop and edit the book from concept to finished product. Id like to thank Dan for his excellent insights, support, encouragement, and guidance throughout the process.
A big thank you to all the technical reviewers who read the manuscript at various stages of its development and contributed invaluable feedback: Adam Hinden, Antonio Mas Rodriguez, Betsy Hoofnagle, Catherine Freytag, Dr. Christian Mennerich, Dan Kacenjar, David Kerns, Ema Battista, Fanick Atchia, Grace Kacenjar, Henry Freytag, Jaqueline Currie, John Pentakalos, Keenan Hom, Kevin Adjaho Atchia, Matthew Giblin, Nathan Sperry, Odysseas Pentakalos, Sam Kerns, Richard Freytag, Savannah Wilson, and Scott M. King.
Thank you also to all the readers who bought and read the MEAP (Manning Early Access Program) versions of the chapters and who took the time to post comments in the Author Online forum. You helped make this a better book!
The Raspberry Pi Foundation, original inventors, and community deserve a special mention. Thank you for designing something that is helping children to learn computer science. Id also like to thank Guido van Rossum, the inventor of Python; the Python Software Foundation; and the Python user community, for creating and maintaining a simple and useful programming language for everyone.
About this book
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. Well 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.