31,19 €
Unleash Python and take your small readers on an adventurous ride through the world of programming
This book is for kids (aged 10 and over). This is book is intended for absolute beginners who lack any knowledge of computing or programming languages and want to get started in the world of programming.
Kids are always the most fast-paced and enthusiastic learners, and are naturally willing to build stuff that looks like magic at the end (when it works!). Programming can be one such magic. Being able to write a program that works helps them feel they've really achieved something. Kids today are very tech-savvy and cannot wait to enter the fast-paced digital world.
Because Python is one of the most popular languages and has a syntax that is quite simple to understand, even kids are eager to use it as a stepping stone to learning programming languages.
This book will cover projects that are simple and fun, and teach kids how to write Python code that works.
The book will teach the basics of Python programming, installation, and so on and then will move on to projects. A total of three projects, with each and every step explained carefully, without any assumption of previous experience.
The book will take a light approach in guiding the little readers through the world of Python. The main idea is to teach by example and let the readers have as much exercises to do, so that they learn faster and can apply their own ideas to the existing examples. The book should get them thinking, by the end, on where they can go next with such a powerful tool at their disposal.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 228
Veröffentlichungsjahr: 2016
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: April 2016
Production reference: 1070416
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78217-506-3
www.packtpub.com
Author
Jessica Ingrassellino
Reviewer
David Whale
Commissioning Editor
Veena Pagare
Acquisition Editor
Aaron Lazar
Content Development Editor
Sachin Karnani
Technical Editor
Rupali R. Shrawane
Copy Editor
Sonia Cheema
Project Coordinator
Nikhil Nair
Proofreader
Safis Editing
Indexer
Rekha Nair
Production Coordinator
Melwyn Dsa
Cover Work
Melwyn Dsa
Jessica Ingrassellino is a multi-talented educator, business leader, and technologist. She received her EdD from Teachers College, Columbia University for music education with an emphasis on assessment.
Jessica is currently employed as the lead software engineer in testing at Bitly, New York City. She transitioned from a teaching career of 10 years to a technology career through a balance of freelance work and social media exposure. Jessica's current work focuses on using Python to develop automated testing tools. She is an ASTQB certified quality assurance engineer with experience in testing web, mobile, and backend applications.
In addition to working at Bitly, Jessica remains committed to education and has founded http://www.teachcode.org/, a nonprofit that teaches computer programming skills to teachers and students in urban or underserved populations through Python and 2D game programming. This new initiative will give teachers the support they need through a standards-referenced curriculum, student-engaging activities, and access to experts in the field of technology.
I would like to thank my students for allowing me to have such fun teaching them Python and learning from their experiences as new programmers. I would also like to thank Cathy Kross and Alice McGowan for being willing to have me in their classes and school and interrupting their daily lives with my code-teaching experiments. Finally, I would like to thank my husband, Nick, for believing in me and helping me through some major writer's block. He never loses faith in me, and for that, I am eternally grateful.
David Whale is a software developer who lives in Essex, UK. He started coding as a schoolboy aged 11, inspired by his school's science technician to build his own computer from a kit. These early experiments lead to some of his code being used in a saleable educational word game when he was only 13.
David has been developing software professionally ever since, mainly writing embedded software that provides intelligence inside electronic products, including automated machinery, electric cars, mobile phones, energy meters, and wireless doorbells.
These days, David runs his own software consultancy called Thinking Binaries, and he spends about half of his time helping customers design software for new electronic products, many of which use Python. The rest of the time, he volunteers for The Institution of Engineering and Technology, running training courses for teachers, designing and running workshops and clubs for school children, running workshops and talks at meet-up events all round the UK, and generally being busy with his Raspberry Pi, BBC micro:bit, and Arduino.
David was the technical editor of Adventures in Raspberry Pi, John Wiley & Sons, the coauthor of Adventures in Minecraft, and he is a regular reviewer and editor of technical books for a number of book publishers.
I was really pleased to be asked to review this exciting new coding book for children. Python is an excellent language for children to learn from a young age, and Jessica has done a great job at helping readers take their first few steps in coding with Python. I hope you will be inspired by the code and ideas in this book and come up with your own ideas to enhance and develop all of the programs further—this is just the start of your exciting new creative journey into coding with Python!
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
As you can guess from the title, this book is designed to teach the basic concepts of Python to kids. This book uses several mini projects so that kids can learn how to solve problems using Python.
Python has grown to become a very popular language for programming web apps, analyzing data, and teaching people how to write code. Python is known for being a simple language to use because it is read much like natural languages, yet it is able to do data analysis very quickly, making it a great language to create websites that handle a lot of data. Another nice thing about Python that makes it fun to use is that people have been working on game libraries, such as pygame, so that people can create graphics programs with Python. The use of simple graphics to make short games is a fun way to learn programming constructs and is especially good for visual learners.
Chapter 1, Welcome! Let's Get Started, discusses Python and setting up a Python development environment on Windows, Mac, and Linux operating systems.
Chapter 2, Variables, Functions, and Users, covers Python data types and functions, as well as how to program Python to get information from the user, store that information, and use it later.
Chapter 3, Calculate This!, uses Python to make a calculator that has multiple mathematical functions. We also learn about working in our file structure and the proper way to save code files.
Chapter 4, Making Decisions – Python Control Flows, covers the use of if, elif, and else, as well as the use of for and while loops, in order to help create programs that make decisions based on user actions.
Chapter 5, Loops and Logic, builds upon what we have learned in the previous chapters and allows us to build a number guessing game. We will build easy and difficult versions of the game.
Chapter 6, Working with Data – Lists and Dictionaries, explains how to use lists and dictionaries to store data. The differences between lists and dictionaries are explained, and we spend time building small lists and dictionaries as well.
Chapter 7, What's in Your Backpack?, allows us to use functions, loops, logic, lists and dictionaries to build a different kind of guessing game. We will also learn about nesting dictionaries and lists.
Chapter 8, pygame, talks about a popular graphical library that is used in Python to make small games. We will learn the fundamental aspects of this library and experiment with some code.
Chapter 9, Tiny Tennis, this game is a clone of a popular game. We will re-create the game using all of the skills that we have learned throughout the book. This is the major project of the book.
Chapter 10, Keep Coding!, shows you all the opportunities that will arise once you read this book.
Appendix, Quick Task Answers, has the answers to all the quick task questions within the chapters.
This book can be used with Windows 10, Mac OS X, or Ubuntu Linux operating systems. Other versions of these operating systems may work; however, this book has been written specifically to address these systems. Additionally, you will need the Internet to download some tools, such as recommended text editors, for your operating system. All recommended downloads are open source.
This book is for kids who are ready to move from graphically-based programming environments, such as Scratch, and into text-based environments. Kids who are ready to create their own projects will engage with this book, especially those who have played games. No prior programming experience is needed to complete the projects in this book; this book is for kids aged 10 years and above, who are ready to learn about Python programming.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/PythonProjectsforKids_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
If you've picked up this book, then you are taking your first step toward building amazing projects using code. Some of you might want to make games, while others might want to learn more about how all of your favorite websites and apps actually work. If you follow the exercises in this book, you'll be able to do the following:
In this book, you will learn Python code. Specifically, you will learn how to design a computer program from the very beginning. It doesn't matter if you have never coded before because each exercise in this book is designed to get you ready to code. If you have coded before, you will find that this book has some really helpful exercises that can help make your code even better. Additionally, there are some more advanced projects toward the end of the book, which you should definitely take a look at!
If you take a look at the Web and search for Python jobs, you will find that many of the highest paying jobs are in Python. Why?
Python is a very flexible and powerful language in the following ways:
So, what will it take to learn Python? If you have never programmed, you will probably want to follow each lesson in order so that you can build the skills you need to make a game or another kind of computer program. The final project in this book will be a game. If you have some other programming experience, such as making modifications to your computer games, using programs such as Scratch or Logo or trying some of the free programming classes on the Internet, then you might decide to skim this book first to see what you already know. It is still recommended that you follow the contents of this book in the order they are presented, as each project builds on the projects that were explained in the previous chapter.
Python teaches all of the basics of an object-oriented programming language, and it is still very powerful. In fact, many Internet companies, most notably Mozilla Firefox and Google, use Python in part or all of their products! Python has also been used to build Django, a free framework to make websites.
It has also been used to build many small video games by people learning about it as well as more advanced programmers. Finally, Python can be used to quickly read and analyze millions of lines of data very quickly! By learning Python, you will be prepared to build a variety of interesting projects, and you will gain the skills necessary to learn other programming languages if you choose to do so.
Before you get started, you need the following basic materials:
All of the code samples in this book are available for download on the Packt Publishing website.
There are many different computer operating systems, but the most common operating systems are Macintosh (Mac), Windows, and Linux. You should follow the installation steps that go with your operating system. There are some subtle but important differences between the systems.
For the projects in this book, we will be using Python 2.7. While there are higher versions than this (3.x), these versions do not work dependably with pygame on Windows, Mac, or Ubuntu Linux as yet. However, this book will be written to use conventions that work in both versions of Python so that projects are easily completed on Raspberry Pi (which uses Python 3.x that's been specially configured with pygame) with just a few modifications. These modifications will be duly noted.
Mac and Linux systems share enough similarities that people who use either Mac or Linux can follow the same set of instructions. These instructions will make note of any differences between Mac and Ubuntu Linux.
At the time of writing, Mac OS X El Capitan comes with Python 2.7 preinstalled, so nothing extra needs to be done at this point.
Ubuntu Linux 15.10 has Python 2.7.10 installed by default, so users of this latest (as of writing this) version of Linux also need to do nothing extra at this point.
Mac and Ubuntu Linux users have Python by default, but finding Python is tricky if you don't know where to look. There is a program called Terminal on both Mac and Linux operating systems. This program allows you to exercise a lot of control over your computer in these ways:
A text editor is a helpful tool for writing and editing Python programs. The terminal is a nice place to test snippets of Python code, but when we want to edit and save the code in order to use it over again, we will need a text editor. Although both Mac and Linux systems come with a text editor, there are some very nice, free editors that have good features. jEdit is one of these editors.
For Mac and Linux, go to http://www.jedit.org/ and download jEdit. Follow the installation instructions.
To successfully complete all of the exercises in this book, you will often need to keep both the terminal and text editor open at the same time on your screen.
This is what the text editor application, jEdit, looks like in Mac and Linux:
Windows users, this setup might require help from your parents. Since Python is not installed by default on Windows, some system adjustments
