Table of Contents
Introduction 1 About This Book 1
Foolish Assumptions 2
Icons Used in This Book 3
Where to Go from Here 3
Part 1: Getting Started with Coding 5
Chapter 1: Welcome To (Or Back To) Coding 7
Why Kids Are Coding 8
What are they learning? 8
How are they learning? 9
What does it mean down the road? 10
Why You Need to Know Coding 11
Fear and loathing (of coding) 11
You may already know more than you think 12
Where Do You Come In? 13
In the classroom 13
Camp or after-school coach 15
Mentor 16
Working with Young Coders 18
Chapter 2: Understanding the Big Ideas 19
Seeing the Big Picture in Coding 19
Acting Out the Big Picture, Unplugged 20
Dramatizing a noncoding process 21
Walking through some daily tasks 22
Creating an Algorithm 23
Turning a picture into words 23
One possible vacuuming algorithm in code 24
Representing Algorithms 26
Acting it out 27
Drawing a picture 27
Creating a storyboard 28
Building a flowchart 28
Writing pseudocode 30
Commenting the bones 31
Organizing with Sequence, Selection, and Repetition 33
Sequence 34
Selection 35
Repetition 36
Including Randomness in Your Coding 38
Chapter 3: Figuring Out Programming Languages 41
What You Want in a Language 42
Free Languages for Tots and Kids 42
The Foos 42
Think & Learn Code-a-Pillar 43
Daisy the Dinosaur 43
Scratch Jr 44
Free Languages for Youth and Tweens 45
Scratch 45
Hopscotch 47
Kodu 47
Languages for Teens and Older 48
Alice 48
MIT App Inventor 2 49
Python 50
JavaScript 53
Java 55
Other Awesome (Not-So-Free) Languages 58
MicroWorlds EX 58
Tynker 58
GameSalad 58
Part 2: Getting Your Hands on Code 61
Chapter 4: Working with Words 63
Communicating with Text 63
Showing Text Onscreen 64
Using pseudocode 64
Using Scratch 64
Using Python 65
Using HTML 66
Using JavaScript in an app 66
Using Java 68
Words In, Words Out 69
Using Scratch 70
Using Python 71
Using HTML and JavaScript 71
Using JavaScript in an app 72
Combining Text Onscreen 74
Using pseudocode 75
Using Scratch 75
Using Python and other languages 75
Formatting Text Onscreen 77
A Mad Libs Example 78
Chapter 5: Knowing Where You Are and Where You’re Going 81
Acting Out Position, Unplugged 82
Setting and Finding Position 85
Using pseudocode 85
Using Scratch to set position 86
Using Scratch to find position 87
Using JavaScript 87
Positioning Objects Randomly 93
Using Scratch 93
Using JavaScript 94
Setting and Finding Direction 95
Using pseudocode 95
Using Scratch 96
Setting Object Direction Randomly 97
Using Scratch 97
Turning 98
Using pseudocode 98
Using Scratch 98
Acting Out Motion, Unplugged 99
Making an Object Move 100
Using pseudocode 100
Using Scratch 101
Using JavaScript 103
Asteroid Blaster 104
Chapter 6: Getting Fancy with Graphics and Sound 107
Sizes of Images and Sounds, Unplugged 108
Activities surrounding images and sounds 108
Knowing your sizes 109
Using Graphics in Your Programs 109
Image file types 109
Creating images 110
Finding images on the web 111
Importing a JPEG or PNG in Scratch 114
Importing a GIF in Scratch 116
Importing a JPEG, PNG, or GIF in JavaScript 117
Adding Sound to Your Programs 117
Sound file types 118
Creating original sounds 118
Finding sounds on the web 119
Importing sounds into Scratch 120
Importing audio into JavaScript 121
Creating a Sound Board 122
Part 3: There is Math on This Test! 125
Chapter 7: Tackling These Ever-Changing Variables 127
Acting Out Variables, Unplugged 127
Variable parts 128
Dramatizing variables 130
I Do Declare (And Initialize) 132
Using pseudocode 132
Using Scratch 133
Using Python 134
Using JavaScript 135
Using Java 136
Checking on Variable Values 137
Using Scratch 138
Using Python 138
Using JavaScript 138
Using Java 140
Incrementing and Decrementing Variables 140
Using pseudocode 140
Using Scratch 141
Using Python 141
Using JavaScript 142
Using Java 142
Creating a Stock Ticker 142
Chapter 8: Computing Using Math 145
Acting Out Math, Unplugged 145
Number types 146
Dramatizing math 146
Doing Simple Math 149
Using pseudocode 149
Using Scratch 149
Using Python 150
Doing Advanced Math Operations 150
Using pseudocode 151
Using Scratch 152
Using Python 153
Oh So Mod — Using the Mod Operation 156
Using pseudocode 157
Using Scratch 157
Using Python 157
Ordering Those Operations (PEMDAS) 157
Using Scratch 158
Using Python 158
Rounding 159
Rounding via casting in Java 160
Rounding decimals to integers via methods 160
Generating and Using Random Numbers 162
Using pseudocode 162
Using Scratch 162
Using Python 163
Coding a Crypto Code Maker 163
Chapter 9: Helping with Logic Operations 167
Simple Logic, Unplugged 167
Programming Simple Conditionals 169
In pseudocode 169
In Scratch 169
In Python 170
In JavaScript 170
In Java 172
Advanced Logic, Unplugged 174
Coding Compound Conditionals (aka, AND, NOT, and OR Will Get You Pretty Far!) 176
In pseudocode 177
Compound conditionals in Scratch 177
In Python 179
In JavaScript 181
In Java 181
Rock, Paper, Scissors 182
Chapter 10: Getting Loopy 185
Loops, Unplugged 185
Repeat fun, unplugged 186
Random loop conditions, unplugged 186
Loop Types and Structures 187
Infinite loops 188
Actions repeated in loops 188
Conditions of loops 188
Using pseudocode 189
Using Scratch 191
Using Python 193
Nesting Loops 196
Using pseudocode 196
Using Scratch 197
Using Python 198
Coding the Classic Fibonacci Sequence 199
Chapter 11: Adding Lists 201
Lists, Unplugged 201
Introducing Lists 203
Using pseudocode 203
Using Scratch 205
Using Java 208
Sorting Lists 215
Selection sort: An easy sorting algorithm 215
Common application: Arranging numbers in order 216
Searching Lists 217
Linear versus binary searching algorithms 217
Common application: Finding a phone number 218
Chapter 12: Coding Subprograms 221
Subprograms, Unplugged 221
Starting with Pseudocode 223
Creating a Spirograph with Subprograms 224
Pseudocode 225
Scratch 225
JavaScript 227
Java 228
Coding Subprograms with Parameters 230
Scratch code block with parameters 230
JavaScript, with parameters 233
Java, with parameters 234
Part 4: Applying What You Know 237
Chapter 13: Fixing Problems by Debugging 239
Debugging, Unplugged 240
Finding Common Syntax Errors 242
Scoping errors 242
Typing errors 243
Incorrect data types 244
Finding Common Semantic Errors 245
Infinite loops 245
Off by one 246
Strategies for Debugging 248
Turning sections on and off 248
Testing sample data 251
Adding output messages 251
Walking Away 253
Chapter 14: Creating a Webpage 255
Getting Set Up 255
Creating a Basic Webpage Layout 261
The skeleton: HTML basics 262
The aesthetics: CSS 265
Getting Fancy with Color and Graphics 272
Adding color to your page 272
Introducing graphics 276
Adding Hyperlinks 278
Going Interactive with JavaScript 280
Adding buttons 280
Changing your page with buttons 282
Combining HTML, CSS, and JavaScript 283
Chapter 15: Building a Mobile Game 289
Getting Started with MIT App Inventor 289
Community and support within MIT App Inventor 291
The layout of MIT App Inventor 292
Using an Emulator versus a Real Device 294
Using the Android Emulator 294
Using a real Android device 295
Testing on the emulator and Android device 295
Designing Mobile Apps 302
Adding the Components in Design View 303
Coding Your Mobile App 306
Getting your puppy moving 306
Setting up your start screen and variables 308
Coding random placement of items 309
Coding collision with items 311
Levels, timers, and final score 312
Distributing Your Apps 315
Chapter 16: Programming Simple Electronics 317
Gathering Your Hardware 317
The micro:bit board 318
Buying the board and components 318
Accessing the Software 320
Navigating the interface 320
Writing and using a program 321
Don’t Wake Baby Gadget 324
Flowcharting the program 324
Writing the code 326
Downloading code to the micro:bit 333
Connecting hardware components 333
Testing the device 334
Trying Wacky and Fun Variations 335
Part 5: The Part of Tens 337
Chapter 17: Ten Do’s and Don’ts for Selecting a Kids Coding Curriculum 339
DO Find the Right Entry Level 340
Getting started in elementary grades 340
Getting started in the middle grades 341
Getting started in high school grades 341
DON’T Assume Cost Equals Quality 343
DO Balance Lessons with Free Exploration 344
DON’T Instantly Dismiss Teaching Languages 344
DO Consult CSTA for Guidance 346
DON’T Buy “Coding” Toys for Babies 346
DO Emphasize the Soft Skills 346
DON’T Let Kids Get Stuck in a Loop 347
DO Present the Bigger Picture 347
DON’T Stereotype Coders 347
Chapter 18: Ten Ways to Keep the Coding Learning Going 349
Unplugged 349
Research Pioneers of Computing 350
Go Lateral from Code 351
Language Tracking 351
Smart Home Projects 352
Include Outside Passions 352
Open-Source Projects 353
Group Projects 354
Community Support 354
Portfolios 355
Index 357