Download Teach Your Kids To Code: A Parent-friendly Guide to Python Programming PDF

TitleTeach Your Kids To Code: A Parent-friendly Guide to Python Programming
TagsAcademic & Education Technology Python
LanguageEnglish
File Size14.9 MB
Total Pages335
Document Text Contents
Page 1




Teach Your Kids to Code is a parent™s and teacher™s guide to teaching kids basic
programming and problem solving usingPython, the powerful language used in
college courses and by tech companies like
Google and IBM.Step-by-step explanations will have kidslearning computational thinking right away,
while visual and game-oriented examples
hold their attention. Friendly introductions
to fundamental programming concepts such
as variables, loops, and functions will help
even the youngest programmers build the
skills they need to make their own cool
games and applications.SHELV
E IN:
PROGRAMMIN
G LANGUAGES/PYTHON
www.nostarch.com
THE F
INES
T IN
GEEK ENTERTAINMENT
ŽFo
r kid
s age
d 9+ (an
d thei
r parents)
$29.95
($34.95 CDN)
Programmingso easy a parentcan do it! Whether you™ve been coding for yearsor have never programmed anything at all,
Teach Your Kids to Code will help you show
your young programmer how to:Explore geometry by drawing colorful
shapes with Turtle graphicsTeach Your Kids to Code is the perfect com-panion to any introductory programming
class or after-school meet-up, or simply your
educational efforts at home. Spend some fun,
productive afternoons at the computer withAdd interactivity, animation, and soundto their appsyour kidsŠ
you can all learn something!ABOU
T TH
E AUTHOR
Dr. Bryson Payne has taught computer
science at the University of North Georgia
for more than 15 years. He has also taught
middle school math and programming, and
continues to work with KŒ12 schools to
promote technology education.Write programs to encode and decode
messages, play Rock-Paper-Scissors,
and calculate how tall someone is in
Ping-Pong balls Create fun, playable games like War, Yahtzee, and PongPAYNETeach Your Kids to CodeA Parent-friendly Guide to Python ProgrammingBryson PayneTeachYour Kidsto Codewww.allitebooks.com



Page 2




Advance Praise for
Teach Your Kids to Code
fiThe text is clear, the graphics are engaging, and the apps are
awesome. This is the programming guide for parents and kids to

enjoy together.fl

ŠAaron Walker, Cybersecurity Expert, NASA
fiThe 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.fl

ŠBindy Auvermann, Executive Director, Next Generation Youth

Development, Inc.
fiProvides the building blocks of a great future in the rapidly
changing world of technology.fl
ŠJoAnne Taylor, former Vice President, Global
Telecommunications, IBM
fiThe 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.fl

ŠDr. Raj Sunderraman, Department Chair of Computer Science,

Georgia State University
fiEvery child on the planet should have this book, and so should
every parent.fl

ŠJames E. Daniel, Jr., Founder, App
Studios,
LLC
fiAn innovative, motivating guide . . . Builds skills that can last a

lifetime.fl

ŠDr. Steven Burrell, Vice President for Information Technology &

CIO, Georgia Southern University
fiThe kind of book I wish I™d had as a kid.fl
ŠScott Hand, Software Engineer, CareerBuilder
www.allitebooks.com



Page 167




7FUNCTIONS:
THERE™S A
NAME
FOR THAT
We™ve made use of a number of
functions
so farŠ
everything from
print() to
input() to
turtle.forward(). But all of these functions have been either built-in or

imported from Python modules and libraries. In this

chapter, we™ll write our
own
functions to do anything
we want, including responding to user actions like

mouse-clicking and keypresses.



Page 168




142
Chapter
7Functions are helpful because they give us the ability to orga-
nize pieces of reusable code, then refer to those pieces later in our
programs by a single short name or command. Take
input() as
an example: it prints a text prompt to ask a user for input, col
-lects what the user types, and passes it to our program as a string

that
we can store in a variable. We reuse the
input() function any
-time we want to know something more from the user. If we didn™t

have this function, we might have to do all that work ourselves

every time we wanted to ask the user for information.
The
turtle.forward() function is
another great visual example: every

time we move the turtle forward to

draw one of the sides of our spirals,

Python draws one pixel at a time

in the direction our turtle is cur-

rently heading on the screen, to the

exact length we ask for. If we didn™t

have the
turtle.forward() function,
we would have to figure out how to

color pixels on the screen, keep track

of locations and angles, and do some

fairly complex math to draw a cer-

tain distance every time.
Without these functions, our programs would be longer, harder
to read, and harder to write. Functions let us take advantage of

the previous programming work of lots of fellow coders. The good

news is that we can also write our own functions to make our code

shorter, easier to read, and more reusable.
In Chapter 6, we built programs that drew random spirals and
a kaleidoscope pattern. We can use functions to make the code in

these programs easier to read and to make parts of the code more

reusable.
Putting
Things
Together with
Functions
Look back at
RandomSpirals.py
on page 115. Everything in the
first
for loop is the code to create just one random spiral. The
for loop uses that code to draw 50 spirals of random color, size, and

location.



Page 334




308
INDEX
turtle module, continued
forward() function, 142Œ143listen() function, 162numinput() function, 47, 59Œ60, 69onkeypress() function, 161onscreenclick() function, 158, 160, 163Œ166, 168Œ170pendown() function, 112penup() function, 112setpos() function, 112textinput() function, 44Œ45, 66window_height() function, 113Œ114window_width() function, 113Œ114write() function, 44turtlesize() function, 162typefaces (fonts), 242Œ243Uupdate() function, 179, 184, 213, 220Œ221, 223,
235, 255up() function, 161upper() function, 96, 99Vvalues, 32
variables, 32Œ34. See also
names of specific

variables
assigning values to, 32
defined, 14, 32, 298
naming, 32Œ33
order of operations, 39
in shell, 38Œ39, 38f
true division, 39ViralFamilySpiral.py
program, 75ViralSpiral.py
program, 68Œ72, 71f, 74Œ75WWar-style card game, 119Œ125building deck of cards, 119Œ120continuing play, 123Œ125
counting cards, 121Œ123
dealing cards, 120Œ121weight_lb variable, 156WhatsMyGrade.py
program, 91Œ92WhatToWear.py
program, 94while loops, 62Œ64, 65Œ66, 78, 108, 123Œ125,
130, 179, 214, 235defined, 299width() function, 25, 150, 159window_height() function, 113Œ114, 135, 139window_width() function, 113Œ114, 135, 139write() function, 44Xx-axis, 70, 111, 180x variable, 14, 14n2, 38Œ39xvel parameter, 219Œ221YYahtzee-style game, 126Œ132probabilities, 131Œ132
setting up, 126Œ127
sorting dice, 127Œ128
testing dice, 128Œ129y-axis, 70Œ71, 111, 180your_age variable, 84your_face variable, 121, 123YourName.py
program, 6Œ7, 7fyour_name variable, 33, 46your_suit variable, 121yvel parameter, 219Œ221


Page 335




UPDATES
Visit
http://www.nostarch.com/teachkids/
for updates, errata, program
files for the projects and programming challenges, and other
information.
DOING MATH WITH PYTHON
Use Programming to Explore
Algebra,
Statistics, Calculus, and More!
by AMIT
SAHA
SPRING
2015, 304
PP
., $29.95
ISBN
978-1-59327-640-9
THE LE
GO® MINDS
TORMS
® EV3
DI
SCOVER
Y BOOK
A Beginner™s
Guide to Building and
Programming Robots
by LAURENS
VALK
JUN
2014, 396
PP
., $34.95
ISBN
978-1-59327-532-7
full color
PYTHON FO
R KIDS
A Playful
Introduction to Programming
by JASON
R. BRIGGS
DEC
2012, 344
PP
., $34.95
ISBN
978-1-59327-407-8
full color
JA
VAS
CR
IPT FO
R KIDSA Playful
Introduction to Programming
by NICK
MORGAN
DEC
2014, 336
PP
., $34.95
ISBN
978-1-59327-408-5
full color
LEARN TO P
ROG
RAM WITH
SCRATCHA Visual
Introduction to Programming
with
Games,
Art, Science, and Math
by MAJED
MARJI
FEB
2014, 288
PP
., $34.95
ISBN
978-1-59327-543-3
full color
LA
URE
N
IPSUM
A Story
About Computer Science

and
Other
Improbable
Things
by CARLOS
BUENO
DEC
2014, 192
PP
., $16.95
ISBN
978-1-59327-574-7
full color
800.420.7240 or 415.863.9900 | [email protected] | www.nostarch.comMORE
SMART
BOOKS
FOR
CURIOUS
KIDS
!

Similer Documents