100% found this document useful (5 votes)
66 views41 pages

Teach Your Kids To Code A Parent Friendly Guide To Python Programming 1st Edition Bryson Payne All Chapters Instant Download

Parent

Uploaded by

velkinthomii
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
66 views41 pages

Teach Your Kids To Code A Parent Friendly Guide To Python Programming 1st Edition Bryson Payne All Chapters Instant Download

Parent

Uploaded by

velkinthomii
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Teach Your Kids to Code A Parent Friendly Guide to


Python Programming 1st Edition Bryson Payne

https://textbookfull.com/product/teach-your-kids-to-code-a-
parent-friendly-guide-to-python-programming-1st-edition-
bryson-payne/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Python for kids a playful introduction to programming 1st


Edition Briggs

https://textbookfull.com/product/python-for-kids-a-playful-
introduction-to-programming-1st-edition-briggs/

textboxfull.com

Learn Python Programming A beginner s guide to learning


the fundamentals of Python language to write efficient
high quality code Romano
https://textbookfull.com/product/learn-python-programming-a-beginner-
s-guide-to-learning-the-fundamentals-of-python-language-to-write-
efficient-high-quality-code-romano/
textboxfull.com

Go H*ck Yourself: A Simple Introduction to Cyber Attacks


and Defence 1st Edition Bryson Payne

https://textbookfull.com/product/go-hck-yourself-a-simple-
introduction-to-cyber-attacks-and-defence-1st-edition-bryson-payne/

textboxfull.com

Make Your Own Python Text Adventure: A Guide to Learning


Programming 1st Edition Phillip Johnson

https://textbookfull.com/product/make-your-own-python-text-adventure-
a-guide-to-learning-programming-1st-edition-phillip-johnson/

textboxfull.com
Functional Python Programming: Use a functional approach
to write succinct, expressive, and efficient Python code,
3rd Edition Lott
https://textbookfull.com/product/functional-python-programming-use-a-
functional-approach-to-write-succinct-expressive-and-efficient-python-
code-3rd-edition-lott/
textboxfull.com

Advanced Guide to Python 3 Programming Hunt

https://textbookfull.com/product/advanced-guide-to-
python-3-programming-hunt/

textboxfull.com

Python for Teenagers: Learn to Program like a Superhero!


2nd Edition Payne

https://textbookfull.com/product/python-for-teenagers-learn-to-
program-like-a-superhero-2nd-edition-payne/

textboxfull.com

Supercharged Python Take Your Code to the Next Level Brian


Overland

https://textbookfull.com/product/supercharged-python-take-your-code-
to-the-next-level-brian-overland/

textboxfull.com

The Official ScratchJr Book Help Your Kids Learn to Code


1st Edition Marina Umaschi Bers

https://textbookfull.com/product/the-official-scratchjr-book-help-
your-kids-learn-to-code-1st-edition-marina-umaschi-bers/

textboxfull.com
Fo r k i d s ag e d 9 + ( a n d th e i r pa r e nts)

Programming
so easy a p
Pa r e n t
T eac h
You r Kids

T
Te
can do it!

ea
ac
to
T o C ode
Teach Your Kids to Code is a parent’s  Create fun, playable games like War,

ch
and teacher’s guide to teaching kids basic Yahtzee, and Pong

h Y
programming and problem solving using  Add interactivity, animation, and sound
Python, the powerful language used in to their apps

Yo
college courses and by tech companies like
Teach Your Kids to Code is the perfect com- A Parent-friendly Guide to Python Programming
Google and IBM.

ou
panion to any introductory programming
Step-by-step explanations will have kids
class or after-school meet-up, or simply your

ur
learning computational thinking right away,
educational efforts at home. Spend some fun,
while visual and game-oriented examples Bryson Payne

r K
productive afternoons at the computer with
hold their attention. Friendly introductions
your kids—you can all learn something!
to fundamental programming concepts such

Kiid
as variables, loops, and functions will help AB O UT TH E AUTH O R
even the youngest programmers build the Dr. Bryson Payne has taught computer

ds
skills they need to make their own cool science at the University of North Georgia
games and applications.

s t
for more than 15 years. He has also taught
Whether you’ve been coding for years middle school math and programming, and
or have never programmed anything at all, continues to work with K–12 schools to

to
Teach Your Kids to Code will help you show promote technology education.

o C
your young programmer how to:
 Explore geometry by drawing colorful
shapes with Turtle graphics

Co
 Write programs to encode and decode

od
messages, play Rock-Paper-Scissors,

de
and calculate how tall someone is in
Ping-Pong balls

PAYNE e
$29.95 ($34.95 CDN)
PROGRAMMING LANGUAGES/PYTHON
SHELVE IN:

w w w.nostarch.com

T H E F I N E ST I N
G E E K E N T E RTA I N M E N T ™
Advance Praise for
Teach Your Kids to Code

“The text is clear, the graphics are engaging, and the apps are
awesome. This is the programming guide for parents and kids to
enjoy together.”
—Aaron Walker, Cybersecurity Expert, NASA

“The energy and excitement Bryson brings to teaching is captured


perfectly in Teach Your Kids to Code, with colorful, captivating
games and graphics that help develop real-world skills.”
—Bindy Auvermann, Executive Director, Next Generation Youth
Development, Inc.

“Provides the building blocks of a great future in the rapidly


changing world of technology.”
—JoAnne Taylor, former Vice President, Global
Telecommunications, IBM​

“The concepts in Teach Your Kids to Code can help any young
person enhance their college prospects and expand their career
opportunities, and Dr. Payne presents these skills through fun,
challenging games and apps.”
—Dr. Raj Sunderraman, Department Chair of Computer Science,
Georgia State University

“Every child on the planet should have this book, and so should
every parent.”
—James E. Daniel, Jr., Founder, App Studios, LLC

“An innovative, motivating guide . . . Builds skills that can last a


lifetime.”
—Dr. Steven Burrell, Vice President for Information Technology &
CIO, Georgia Southern University

“The kind of book I wish I’d had as a kid.”


—Scott Hand, Software Engineer, CareerBuilder
“Dr. Bryson Payne is a computer scientist and professor of the
highest caliber, and with Teach Your Kids to Code, he brings the
power of computers within easy reach for readers young and old.”
—Dr. Antonio Sanz Montemayor, Informatics Professor,
Universidad Rey Juan Carlos, Spain

“A brilliant combination of engaging, imaginative apps and


valuable, lifelong skills.”
—Ted Cunningham, author of The Power of Home

“Teach Your Kids to Code and the logical thinking it introduces


will help build the next generation of technology leaders.”
—N. Dean Meyer, author and executive coach

“This book can jump-start your child’s success in a high-tech


world.”
—Ken Coleman, leadership author and former radio host of
The Ken Coleman Show

“Dr. Payne set us on the path that led us to our dream jobs! With
Teach Your Kids to Code, he’s providing parents and teachers
everywhere the chance to do the same for the next generation of
creative problem-solvers.”
—Shah and Susan Rahman, Riot Games

“Bryson helps people improve their lives with technology. His book
does the same.”
—Ash Mady, Technical Manager, RedHat, Inc.

“Enjoyable and accessible to parents and children alike.”


—Steve McLeod, Deputy CIO, University of North Georgia

“Dr. Payne used robots, games, and fun programs to motivate me


in college, and Teach Your Kids to Code extends that same passion
for coding cool apps beyond the walls of the campus.”
—Bobby Brown, Lead Developer, GetUWired
Teach Your Kids to Code
Teach
You r Ki ds
to Code
A Pa r e n t- F r i e n d ly G u i d e to
Python Programming

B y B r ys o n Pay n e

San Francisco
Teach Your Kids to Code. Copyright © 2015 by Bryson Payne.

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information storage
or retrieval system, without the prior written permission of the copyright owner and the publisher.

19 18 17 16 15    1 2 3 4 5 6 7 8 9

ISBN-10: 1-59327-614-1
ISBN-13: 978-1-59327-614-0

Publisher: William Pollock


Production Editor: Riley Hoffman
Cover Illustration: Josh Ellingson
Illustrator: Miran Lipovac�a
Developmental Editors: Tyler Ortman and Leslie Shen
Technical Reviewers: Michelle Friend and Ari Lacenski
Copyeditor: Rachel Monaghan
Compositor: Riley Hoffman
Proofreader: Paula L. Fleming
Indexer: BIM Indexing & Proofreading Services

For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 415.863.9900; [email protected]
www.nostarch.com

Library of Congress Cataloging-in-Publication Data


Payne, Bryson.
Teach your kids to code : a parent-friendly guide to Python programming / by Bryson Payne. -- 1st edition.
pages cm
Includes index.
Summary: "A guide to teaching basic programming skills for parents and teachers, with step-by-step
explanations, visual examples, and exercises. Covers programming concepts including loops, lists, functions,
and variables, and how to build games and applications"-- Provided by publisher.
ISBN 978-1-59327-614-0 -- ISBN 1-59327-614-1
1. Python (Computer program language)--Study and teaching (Elementary) 2. Computer programming--Study
and teaching (Elementary) 3. Python (Computer program language)--Study and teaching (Middle school) 4.
Computer programming--Study and teaching (Middle school) I. Title.
QA76.73.P98P39 2015
005.13'3--dc23
2015006794

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc.
Other product and company names mentioned herein may be the trademarks of their respective
owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are
using the names only in an editorial fashion and to the benefit of the trademark owner, with no inten-
tion of infringement of the trademark.

The information in this book is distributed on an “As Is” basis, without warranty. While every precau-
tion has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall
have any liability to any person or entity with respect to any loss or damage caused or alleged to be
caused directly or indirectly by the information contained in it.
To Alex and Max,
my two favorite coders
About the Author
Dr. Bryson Payne is a tenured professor of computer science at the
University of North Georgia, where he has taught aspiring coders
for more than 15 years. His students have built successful careers
at Blizzard Entertainment, Riot Games, Equifax, CareerBuilder,
and more. He was the first department head of computer science at
UNG, and he holds a PhD in computer science from Georgia State
University. In addition, he works extensively with K–12 schools to
promote technology education.
Dr. Payne has been programming for more than 30 years. The
first program he sold was to RUN magazine (Commodore 64) for
their “Magic” column in 1985, for $10.
Dr. Payne lives north of Atlanta, Georgia, with his wife, Bev,
and two sons, Alex and Max.

About the Illustrator


Miran Lipovac�a is the author of Learn You a Haskell for Great
Good!. He enjoys boxing, playing bass guitar, and, of course,
­drawing. He has a fascination with dancing skeletons and the
number 71, and when he walks through automatic doors he pre-
tends that he’s actually opening them with his mind.

About the Technical Reviewer


Ari Lacenski is a developer of Android applications and Python
software. She lives in San Francisco. She writes about Android
programming at http://gradlewhy.ghost.io/, mentors with Women
Who Code, and plays songs about space pirates on guitar.
Brief Contents

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

Introduction: What Is Coding and Why Is It Good for Your Kids? . . . . . . . xxi

Chapter 1: Python Basics: Get to Know Your Environment . . . . . . . . . . . . . 1


Chapter 2: Turtle Graphics: Drawing with Python . . . . . . . . . . . . . . . . . . . 11
Chapter 3: Numbers and Variables: Python Does the Math . . . . . . . . . . . . 31
Chapter 4: Loops Are Fun (You Can Say That Again) . . . . . . . . . . . . . . . . . 53
Chapter 5: Conditions (What If?) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Chapter 6: Random Fun and Games: Go Ahead, Take a Chance! . . . . . . 105
Chapter 7: Functions: There’s a Name for That . . . . . . . . . . . . . . . . . . . . . 141
Chapter 8: Timers and Animation: What Would Disney Do? . . . . . . . . . . 175
Chapter 9: User Interaction: Get into the Game . . . . . . . . . . . . . . . . . . . . 207
Chapter 10: Game Programming: Coding for Fun . . . . . . . . . . . . . . . . . . . 231

Appendix A: Python Setup for Windows, Mac, and Linux . . . . . . . . . . . . 263


Appendix B: Pygame Setup for Windows, Mac, and Linux . . . . . . . . . . . 279
Appendix C: Building Your Own Modules . . . . . . . . . . . . . . . . . . . . . . . . . 289

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Contents in Detail

Acknowledgments xix

Introduction
What Is Coding and Why Is It Good for Your Kids? xxi
Why Should Kids Learn to Code? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Coding Is Fun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Coding Is a Valuable Job Skill . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Where Can Kids Learn to Code? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
How to Use This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv
Explore! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv
Do It Together! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Coding = Solving Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi

1
Python Basics: Get to Know Your Environment 1
Getting Started with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1. Download Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2. Install Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3. Test Python with a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Writing Programs in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Running Programs in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
#1: Mad Libs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
#2: More Mad Libs! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2
Turtle Graphics: Drawing with Python 11
Our First Turtle Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
How It Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
What Happens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Turtle on a Roll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Turtle Roundup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Adding a Touch of Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
A Four-Color Spiral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Changing Background Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
One Variable to Rule Them All . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
#1: Changing the Number of Sides . . . . . . . . . . . . . . . . . . . . . . . . . . 27
#2: How Many Sides? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
#3: Rubber-Band Ball . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

3
Numbers and Variables: Python Does the Math 31
Variables: Where We Keep Our Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Numbers and Math in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Python Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Python Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Doing Math in the Python Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Syntax Errors: What Did You Say? . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Variables in the Python Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Programming with Operators: A Pizza Calculator . . . . . . . . . . . . . 39
Strings: The Real Characters in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Improving Our Color Spiral with Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Lists: Keeping It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Python Does Your Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
#1: Circular Spirals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
#2: Custom Name Spirals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

4
Loops Are Fun (You Can Say That Again) 53
Building Your Own for Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Using a for Loop to Make a Rosette with Four Circles . . . . . . . . . . 56
Modifying Our for Loop to Make a Rosette with Six Circles . . . . . . 58
Improving Our Rosette Program with User Input . . . . . . . . . . . . . . . . . . . . 59
Game Loops and while Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
The Family Spiral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Putting It All Together: Spiral Goes Viral . . . . . . . . . . . . . . . . . . . . . . . . . . 68
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
#1: Spiral Rosettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
#2: A Spiral of Family Spirals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

xiv  Contents in Detail
5
Conditions (What If?) 77
if Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Meet the Booleans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
You’re Not Old Enough! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
else Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Polygons or Rosettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Even or Odd? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
elif Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Complex Conditions: if, and, or, not . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Secret Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Messin’ with Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
The Value of Character(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Our Encoder/Decoder Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
#1: Colorful Rosettes and Spirals . . . . . . . . . . . . . . . . . . . . . . . . . . 102
#2: User-Defined Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

6
Random Fun and Games: Go Ahead, Take a Chance! 105
A Guessing Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Colorful Random Spirals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Pick a Color, Any Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Getting Coordinated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
How Big Is Our Canvas? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Rock-Paper-Scissors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Pick a Card, Any Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Stacking the Deck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Dealing Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Counting Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Keeping It Going . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Roll the Dice: Creating a Yahtzee-Style Game . . . . . . . . . . . . . . . . . . . . . 126
Setting Up the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Sorting the Dice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Testing the Dice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Kaleidoscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Contents in Detail  xv
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
#1: Random Sides and Thickness . . . . . . . . . . . . . . . . . . . . . . . . . . 138
#2: Realistic Mirrored Spirals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
#3: War . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

7
Functions: There’s a Name for That 141
Putting Things Together with Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Defining random_spiral() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Calling random_spiral() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Parameters: Feeding Your Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Smileys at Random Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Return: It’s What You Give Back That Counts . . . . . . . . . . . . . . . . . . . . . 153
Returning a Value from a Function . . . . . . . . . . . . . . . . . . . . . . . . 153
Using Return Values in a Program . . . . . . . . . . . . . . . . . . . . . . . . . 154
A Touch of Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Handling Events: TurtleDraw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Listening for Keyboard Events: ArrowDraw . . . . . . . . . . . . . . . . . 160
Handling Events with Parameters: ClickSpiral . . . . . . . . . . . . . . . 163
Taking It One Step Further: ClickandSmile . . . . . . . . . . . . . . . . . 166
ClickKaleidoscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
The draw_kaleido() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
The draw_spiral() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
#1: Mirrored Smileys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
#2: More Ping-Pong Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . 173
#3: A Better Drawing Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

8
Timers and Animation: What Would Disney Do? 175
Getting All GUI with Pygame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Drawing a Dot with Pygame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
What’s New in Pygame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
The Parts of a Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Timing It Just Right: Move and Bounce . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Moving a Smiley . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Animating a Smiley with the Clock Class . . . . . . . . . . . . . . . . . . . 188
Bouncing a Smiley Off a Wall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Bouncing a Smiley Off Four Walls . . . . . . . . . . . . . . . . . . . . . . . . . 197

xvi  Contents in Detail
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
#1: A Color-Changing Dot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
#2: 100 Random Dots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
#3: Raining Dots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

9
User Interaction: Get into the Game 207
Adding Interaction: Click and Drag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Clicking for Dots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Dragging to Paint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Advanced Interaction: Smiley Explosion . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Smiley Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Setting Up Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Updating Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Bigger and Smaller Smileys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
SmileyPop, Version 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Detecting Collisions and Removing Sprites . . . . . . . . . . . . . . . . . . 224
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
#1: Randomly Colored Dots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
#2: Painting in Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
#3: Throwing Smileys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

10
Game Programming: Coding for Fun 231
Building a Game Skeleton:
Smiley Pong, Version 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Drawing a Board and Game Pieces . . . . . . . . . . . . . . . . . . . . . . . . . 234
Keeping Score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Showing the Score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Adding Difficulty and Ending the Game: Smiley Pong, Version 2.0 . . . . . 245
Game Over . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Play Again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Faster and Faster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Adding More Features: SmileyPop v2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Adding Sound with Pygame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Tracking and Displaying Player Progress . . . . . . . . . . . . . . . . . . . 254
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

Contents in Detail  xvii
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
#1: Sound Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
#2: Hits and Misses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
#3: Clear the Bubbles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

A
Python Setup for Windows, Mac, and Linux 263
Python for Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Download the Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Run the Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Try Out Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Python for Mac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Download the Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Run the Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Try Out Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Python for Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

B
Pygame Setup for Windows, Mac, and Linux 279
Pygame for Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Pygame for Mac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Python 2.7 and Pygame 1.9.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Pygame for Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Pygame for Python 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

C
Building Your Own Modules 289
Building the colorspiral Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Using the colorspiral Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Reusing the colorspiral Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

Glossary 295

Index 301

xviii  Contents in Detail
Acknowledgments
This book would not have been possible without the exceptional
support of the No Starch Press team. Thanks especially to Bill
Pollock for believing in the project; to Tyler Ortman for champion-
ing and editing; and to Leslie Shen, Riley Hoffman, Lee Axelrod,
Mackenzie Dolginow, Serena Yang, and Laurel Chun for their
indefatigable editing, reviewing, marketing, and production prowess
and for the countless ways they helped me improve this book from
my original manuscript. And thanks to Rachel Monaghan and
Paula Fleming for their help copyediting and proofreading.
Thanks to Michelle Friend and Ari Lacenski for their thought-
ful and thorough technical review, and to Conor Seng for being the
first to read the book and try out the programs—at 10 years old.
Thanks to Miran Lipovac�a for his amazing illustrations—they
bring the kind of life to the text that I could only have dreamed of.
Thanks to my father-in-law, Norman Petty, a retired IBM’er,
who began teaching himself Python using an early draft of the book.
Special thanks to my wife and best friend, Bev, for her con-
stant support, and to my amazing sons, Alex and Max, for helping
test every program and suggesting improvements. This book and
my entire life are infinitely better because of the three of you.
Finally, thanks to my mom, Esta, who encouraged me to love
learning and solving puzzles.
Introduction
What Is Coding and Why
Is It Good for Your Kids?

Computer programming, or coding, is a crucial skill


every child should be learning. We use computers
to solve problems, play games, help us work more
effectively, perform repetitive tasks, store and recall
information, create something new, and connect with
our friends and the world. Understanding how to code
puts all this power at our fingertips.
Everyone can learn to code; it’s just like solving a puzzle or a
riddle. You apply logic, try a solution, experiment a little more, and
then solve the problem. The time to start learning to code is now!
We are at an unprecedented time in history: never before could bil-
lions of people connect with one another every day like we do now
with computers. We live in a world of many new possibilities, from
electric cars and robot caregivers to drones that deliver packages
and even pizza.
If your children start learning to code today, they can help
define this fast-changing world.

Why Should Kids Learn to Code?


There are many great reasons to learn computer programming,
but here are my top two:
• Coding is fun.
• Coding is a valuable job skill.

Coding Is Fun
Technology is becoming a part of everyday life. Every company,
charitable organization, and cause can benefit from technology.
There are apps to help you buy, give, join, play, volunteer, connect,
share—just about anything you can imagine.
Have your children wanted to build their own level for their
favorite video game? Coders do that! What about create their own
phone app? They can bring that idea to life by programming it on
a computer! Every program, game, system, or app they’ve ever
seen was coded using the same programming building blocks
they’ll learn in this book. When kids program, they take an active
role in technology—they’re not just having fun, they’re making
something fun!

Coding Is a Valuable Job Skill


Coding is the skill of the 21st century. Jobs today require more
problem-solving ability than ever before, and more and more
careers involve technology as an integral requirement.
The US Bureau of Labor Statistics predicts that more
than 8 million technology jobs will be created in just the next
five years. Seven of the ten fastest-growing occupations in the

xxii  Introduction
2014–2015 Occupational Outlook Handbook that do not require
master’s or doctoral degrees are in the computer science or infor-
mation technology (IT) fields.
Mark Zuckerberg was a college student working from his dorm
room when he developed the first version of Facebook in 2004. Just
10 years later, 1.39 billion people were using Facebook every month
(source: http://newsroom.fb.com/company-info/). Never before in
history had an idea, product, or service been able to engage a billion
people in under a decade. Facebook demonstrates the power of tech-
nology to reach more people, faster, than ever before.

Where Can Kids Learn to Code?


This book is only the beginning. There are more places than ever
to learn programming; websites like Code.org, Codecademy (see
Figure 1), and countless others teach basic to advanced program-
ming in a variety of in-demand programming languages. Once
you’ve completed this book with your kids, your children can take
free courses through websites like EdX, Udacity, and Coursera to
extend their learning even further.

Figure 1: Codecademy teaches you how to program step by step in a


variety of languages.

“Coding clubs” are a great way to have fun learning with


friends. Getting a college degree in a relevant field is still one of
the best ways to prepare for a career, but even if college isn’t an
option at the moment, your kids can begin building a program-
ming portfolio and demonstrating their skills as a programmer
and problem-solver today.

What Is Coding and Why Is It Good for Your Kids?  xxiii


How to Use This Book
This book isn’t just for kids—it’s for parents, teachers, students,
and adults who want to understand the basics of computer pro-
gramming, both to have fun and to gain access to new jobs in the
high-tech economy. No matter what your age, you can have a
great time learning the basics of programming. The best way to do
this is to experiment and work together.

Explore!
Learning to program is exciting if you’re willing to try new things.
As you and your kids follow along with the programs in this book,
try changing numbers and text in the code to see what happens to
the program. Even if you break it, you’ll learn something new by
fixing it. In the worst case, all you have to do is retype the example
from the book or open the last saved version that worked. The point
of learning to code is to try something new, learn a new skill, and
solve problems in a new way. Make sure your kids are playing
around—testing their code by changing something, saving the pro-
gram, running it, seeing what happens, and fixing any errors.
The point of learning to code is to try something new, learn
a new skill, and solve problems in a new way. Test your code by
changing something, saving the program, running it, seeing what
happens, and fixing errors if needed.
For example, I wrote some code to make a colorful drawing
(Figure 2) and then went back, changed some numbers here and
there, and tried running the program again. This gave me another
drawing that was completely different but just as amazing. I went
back again, changed some other numbers, and got yet another beau-
tiful, unique drawing. See what you can do just by playing around?

Figure 2: Three colorful spiral drawings I created by trying different values in a line of code in
one program

xxiv  Introduction
Do It Together!
Experimenting with code is a great way to learn how programs
work, and it’s even more effective if you work with someone else.
Whether you’re teaching a child or student or studying for yourself,
it’s not just more fun to play with code together—it’s also more
effective.
For example, in the Suzuki Method of music instruction, par-
ents attend lessons with their child and even study ahead so they
can help their child between lessons. Starting early is another
hallmark of the Suzuki Method; kids can start formal study by the
age of three or four.
I began introducing my two sons to programming when they
were two and four, and I encouraged them to have fun by changing
small parts of each program, like the colors, shapes, and sizes of
shapes.
I learned to program at the age of 13 by typing program
examples from books and then modifying them to make them do
something new. Now, in the computer science courses I teach, I
often give students a program and encourage them to play around
with the code to build something new.
If you’re using this book to teach yourself, you can work with
others by finding a friend to work through examples with you or
by starting an after-school or community coding club (see http://
coderdojo.com/ or http://www.codecademy.com/afterschool/ for
ideas and tips). Coding is a team sport!

Online Resources
All the program files for
this book are available at
http://www.nostarch.com/
teachkids/, as well as sample
solutions for the Programming
Challenges and other informa-
tion. Download the programs
and experiment with them
to learn even more. Use the
sample solutions if you get
stumped. Check it out!

What Is Coding and Why Is It Good for Your Kids?  xxv


Coding = Solving Problems
Whether your child is 2 years old and learning to count or 22
and looking for a new challenge, this book and the concepts it
introduces are a great pathway to a rewarding, inspiring pastime
and better career opportunities. People who can program—and
thus solve problems quickly and effectively—are highly valued in
today’s world, and they get to do interesting, fulfilling work.
Not all of the world’s problems can be solved with technology
alone, but technology can enable communication, collaboration,
awareness, and action at a scale and speed never before imagined.
If you can code, you can solve problems. Problem-solvers have the
power to make the world a better place, so start coding today.

xxvi  Introduction
1
Python Basics:
Get to Know Your Environment

Just about anything could have a computer in


it—a phone, a car, a watch, a video game console,
an exercise machine, a medical device, industrial
equipment, a greeting card, or a robot. Computer pro-
gramming, or coding, is how we tell a computer to
perform a task, and understanding how to code puts
the power of computers at your fingertips.
Computer programs—also called applications, or apps—tell
computers what to do. A web app can tell the computer how to keep
track of your favorite music; a game app can tell the computer how
to display an epic battlefield with realistic graphics; a simple app
can tell the computer to draw a beautiful spiral like the hexagon in
Figure 1-1.

Figure 1-1: A colorful spiral graphic

Some apps are composed of thousands of lines of code,


while others may be just a few lines long, like the program
NiceHexSpiral.py in Figure 1-2.

2  Chapter 1
Figure 1-2: NiceHexSpiral.py, a short Python
program that draws the spiral in Figure 1-1

This short program draws the colorful spiral shown in Fig-


ure 1-1. I wanted a pretty picture to use as an example in this
book, so I decided to solve that problem using a computer pro-
gram. First I sketched out an idea, and then I started coding.
In this chapter, we’ll download, install, and learn to use the
programs that will help us write code to build any kind of app you
can imagine.

Getting Started with Python


To begin coding, we have to speak the computer’s language.
Computers need step-by-step instructions, and they can only
understand certain languages. Just like a person from Russia
might not be able to understand English, computers only
understand languages made for them.
Computer code is written in program-
ming languages like Python, C++, Ruby,
or JavaScript. These languages allow us
to “talk” to our computer and give it com-
mands. Think about when you teach a
dog to do tricks—when you give the “sit”
command, he sits; when you say “speak,”
he barks. The dog understands those
simple commands, but not much else
you say.

Python Basics: Get to Know Your Environment   3


Exploring the Variety of Random
Documents with Different Content
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite
these efforts, Project Gutenberg™ electronic works, and the
medium on which they may be stored, may contain “Defects,”
such as, but not limited to, incomplete, inaccurate or corrupt
data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES -


Except for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU
AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE,
STRICT LIABILITY, BREACH OF WARRANTY OR BREACH
OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER
THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR
ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE
OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF
THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If


you discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person or
entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like