Schweitzer Fachinformationen
Wenn es um professionelles Wissen geht, ist Schweitzer Fachinformationen wegweisend. Kunden aus Recht und Beratung sowie Unternehmen, öffentliche Verwaltungen und Bibliotheken erhalten komplette Lösungen zum Beschaffen, Verwalten und Nutzen von digitalen und gedruckten Medien.
A guide for kids who want to learn coding
Coding is quickly becoming an essential academic skill, right up there with reading, writing, and arithmetic. This book is an ideal way for young learners ages 8-13 who want more coding knowledge than you can learn in an hour, a day, or a week.
Written by a classroom instructor with over a decade of experience teaching technology skills to kids as young as five, this book teaches the steps and logic needed to write code, solve problems, and create fun games and animations using projects based in Scratch and JavaScript. This 2nd Edition is fully updated to no longer require any limited-time software downloads to complete the projects.
Whether you're a kid ready to make fun things using technology or a parent, teacher, or mentor looking to introduce coding in an eager child's life, this fun book makes getting started with coding fun and easy!
Camille McCue, PhD is a STEM educator and leader who has worked for IBM, NASA, PBS, and numerous independent schools. She has taught every grade from kindergarten to grad school, covering topics ranging from Scratch to AP computer science. Camille is co-author of Helping Kids with Coding For Dummies and author of Getting Started with Coding and Getting Started with Engineering.
Introduction 1
About This Book 1
Foolish Assumptions 2
Icons Used in This Book 3
Beyond the Book 4
Where to Go from Here 4
Part 1: Getting Started 5
Chapter 1: What Is Coding? 7
What Languages Will I Use? 8
What Does a Computer Program Look Like? 9
A Hello World! Example 10
Recipe for a Program 11
Planning a Program 13
Prepping Yourself to Code 15
Coding Cool Stuff 16
Chapter 2: Working with Programming Languages and IDEs 18
Basic IDE Setup and Navigation 19
Adding Hardware 33
Getting Fancier with User Interfaces 36
Chapter 3: When Things Go Wrong 40
Syntax Errors 41
Logic Errors 42
Debugging Scratch Programs 43
Debugging App Lab Programs 45
Debugging MakeCode Programs 49
Commenting Out Code when Debugging 51
Part 2: Sounds, Color, Random Surprises 53
Chapter 4: Orchestra 55
Brainstorm 56
Sidebar: Event-driven programming 56
Start a New Project 57
Add a Backdrop 58
Add Instrument Sprites 59
Add a Singer Sprite and Modify Its Costume 61
Code Each Instrument to Play a Sound 63
Sidebar: Parallel processing 67
Save, Test, and Debug Your Program 67
Share Your Program with the World 68
Enhance Your Toy 68
Chapter 5: Foley Sound Generator 69
Brainstorm 69
Sidebar: User Interfaces 70
Start a New Project 71
Add a Background 72
Add Sound and Stop Sounds Buttons 75
Code the Sound Buttons to Play 78
Code the Stop Sounds Button to Stop Sounds 80
Save, Test, and Debug Your App 82
Share Your App with the World 82
Enhance Your App 82
Chapter 6: Lucky Numbers 83
Brainstorm 84
Start a New Project 85
Code Button A 85
Sidebar: Coding Randomness 87
Code Button B 87
Save, Test, and Debug Your Program 89
Transfer Your Program to the micro:bit 89
Share Your Program with the World 90
Enhance Your Toy 90
Chapter 7: Mondrian Art Toy 91
Brainstorm 92
Start a New Project 92
Add a Background Color 93
Sidebar: RGBA Color 95
Add a Title Label 96
Add Fill and Clear Buttons 97
Code a Canvas and Paintbrush 99
Code to Draw a Rectangle 101
Code to Fill Rectangles with Color 102
Code a Clear Button to Erase a Painting 103
Save, Test, and Debug Your App 105
Share Your App with the World 105
Enhance Your App 106
Part 3: Moving from Here to There, Again and Again 107
Chapter 8: Emoji Explosion 109
Brainstorm 110
Start a New Project 110
Add a Backdrop 110
Add an Emoji Sprite 111
Code the Stage to Play a Sound 113
Code the Green Flag for the Emoji Sprite 115
Sidebar: Cloning and Inheritance 116
Code the makeEmojis Block 118
Code when I start as a clone for the Emoji Sprite 119
Code the explode Block for the Emoji Clones 121
Save, Test, and Debug Your Program 123
Share Your Program with the World 124
Enhance Your Animated Scene 124
Sidebar: Setting Position 124
Sidebar: Setting Direction 127
Sidebar: Moving 129
Sidebar: Simple Repeat Loops 130
Sidebar: New Blocks (aka Functions) 131
Chapter 9: Smelephant 133
Brainstorm 134
Start a New Project 134
Add a Backdrop 134
Add a Smelephant Sprite 135
Sidebar: Rotation Style in Scratch 137
Code the Green Flag Code of the Smelephant 138
Code the Smelephant's Up Arrow Key Control 139
Sidebar: Animating Shapes 141
Code Arrow Keys for Moving the Smelephant Down, Left, and Right 144
Add a Flower Sprite 145
Code the Green Flag for the Flower Sprite 147
Code the makeFlowers Block 148
Code when I start as a clone for the Flower Sprite 150
Code the getSmelled Block for the Flower Clones 151
Add a Monkey Sprite 153
Code the Green Flag for the Monkey 154
Code the chase Block 155
Save, Test, and Debug Your Program 158
Share Your Program with the World 158
Enhance Your Animated Scene 158
Sidebar: Key Control 159
Sidebar: Collisions 160
Sidebar: Show and Hide 162
Part 4: Variables, Simple Conditionals, and I/O 163
Chapter 10: Mascot Greeter 165
Brainstorm 166
Start a New Project 166
Sidebar: Inputs and Outputs (I/O) 167
Add a Backdrop 168
Add a Mascot Sprite 168
Add Text-to-Speech Commands 169
Sidebar: Strings and String Operations 170
Code the Mascot Sprite to Greet 171
Save, Test, and Debug Your Program 173
Share Your Program with the World 173
Enhance Your Program 173
Chapter 11: Weird Text Message 174
Brainstorm 175
Start a New Project 175
Name the Input Screen for the App 176
Add a Background Color to the Input Screen 176
Add an Instruction Label 177
Add Category Labels and Text Input Fields 178
Add a Button to Trigger the Action 181
Add and Name an Output Screen 183
Add a Message Image to the Output Screen 183
Add a Message Label to the Output Screen 185
Code the App 186
Save, Test, and Debug Your App 188
Share Your App with the World 189
Enhance Your App 189
Sidebar: Dilbert's Jargonator 190
Sidebar: ELIZA, the Turing Test, and AI 191
Chapter 12: Vote Machine 192
Brainstorm 193
Start a New Project 193
Rename the Screen 194
Add a Title Label to the App 194
Add Images for the Candidates 195
Add Labels for Each Candidate 197
Code Variables for the First Candidate 198
Code the First Candidate to Register a Vote 199
Sidebar: Working with Number Variables 200
Code Variables for the Remaining Candidates 204
Sidebar: Changing and Incrementing Variable Values 205
Code Remaining Candidates to Register Votes 206
Save, Test, and Debug Your App 207
Share Your App with the World 208
Enhance Your App 208
Chapter 13: Happy New Year! 209
Brainstorm 210
Start a New Project 210
Add a Backdrop 211
Add a Glittery Ball 211
Code the Ball to Drop 213
Create a Countdown Variable 214
Sidebar: Google Language Translation 217
Add Text-to-Speech and Translate Commands 217
Add a Cheer Sound to the Ball Sprite 218
Code the Countdown Clock 219
Sidebar: Decrementing a Variable 221
Save, Test, and Debug Your Program 223
Sidebar: Simple Conditionals and Booleans 223
Share Your Program with the World 224
Enhance Your Toy 224
Chapter 14: Light Theremin 225
Brainstorm 226
Start a New Project 227
Code the First Sound Conditional 228
Code More Sound Conditionals 231
Sidebar: Advanced Conditionals 232
Save, Test, and Debug Your Program 236
Sidebar: IoT and Sensors in Circuits 236
Transfer Your Program to the micro:bit 237
Share Your Program with the World 238
Enhance Your Toy 238
Part 5: Lists, Loops, and Logic 239
Chapter 15: Magic 8-Ball 241
Brainstorm 242
Start a New Project 242
Code on start 243
Sidebar: Simple Lists (Arrays) 245
Code on shake 246
Save, Test, and Debug Your Program 248
Transfer Your Program to the micro:bit 249
Share Your Program with the World 249
Enhance Your Toy 249
Sidebar: eToys 250
Chapter 16: Sock Sort 252
Brainstorm 253
Start a New Project 253
Add a Backdrop 254
Add Red and White Sock Sprites 255
Add Mixed, Red, and White Lists 256
Code the Green Flag (Create List) 258
Code the clearLists Block 263
Code the Sorting Process 264
Save, Test, and Debug Your Program 268
Share Your Program with the World 268
Enhance Your Program 268
Sidebar: Sorting Algorithms 269
Chapter 17: Evil Olive 272
Brainstorm 273
Start a New Project 273
Add a Background Image to the Screen 273
Add an Instruction Label 274
Add a Text Input Field 276
Create and Add Evil Olive to the Screen 277
Add a Message Label to the Screen 278
Code the App 279
Save, Test, and Debug Your App 282
Share Your App with the World 283
Enhance Your App 283
Sidebar: For Loops 284
Sidebar: Searching Algorithms 285
Chapter 18: Sushi Matchup 286
Brainstorm 287
Start a New Project 288
Draw a Toy Interface on the Backdrop 288
Add a Button Sprite 292
Add Reels Sprites 293
Add a Status Sprite 296
Code the Button to Trigger the Spin 299
Create wear Variables 302
Add Sounds 304
Code the Reels to Spin 306
Code the checkMatch Block 309
Code the status Sprite 314
Save, Test, and Debug Your Program 315
Share Your Program with the World 315
Enhance Your Program 316
Sidebar: Broadcasting 316
Sidebar: Logical Operators 317
Part 6: Onwards and Upwards 319
Chapter 19: Creating and Sharing 321
Programming Your Own Ideas 322
Sharing and Showcasing Your Work 325
Chapter 20: Where to Go from Here 336
Upping Your Game 337
Next Steps 340
Index 343
CHAPTER 1
You know that coding has to do with building the apps you use and controlling the technology in your life, but what exactly is coding? Coding, also known as computer programming, is creating instructions for a computing device to do something. You use a language to communicate with other people, and computers use a coding language to communicate. And just as you can learn to write, speak, and understand languages different from the one you first learned as a toddler, you can learn to communicate in a coding language - so that you can "talk to" computers!
You're probably wondering whether coding is hard to learn. The answer is that it's easy to get started with coding, and easy to write real computer programs to perform all sorts of tasks! Unlike the early days of coding, when computer programmers talked to computers using long sequences of numbers (0s and 1s), you can now write code by using words and symbols that you can understand easily. For example, you can tell an app to play a sound three times ("boom boom boom!") with a command such as repeat 3 (play sound boom). Neat, huh?
repeat 3 (play sound boom)
This type of human-friendly coding, which is called a high-level language, is what you will use when you're first learning to code. (Many professional programmers also use high-level languages.) Later, I talk more about high-level languages and the languages you'll use in this book.
You're probably also wondering whether you can make anything cool as a new coder. Yes, you can! In this book, you write code to build games, toys, and electronic gadgets. Everything you create you can play with and share with your friends and family.
This book is filled with great projects you can do to learn the basics of coding and make real apps. You'll be using two programming languages to code: Scratch and JavaScript.
In the Scratch language, you build code with blocks (also called tiles) that snap together to make complete programs. Scratch is a learning language, created especially for kids, and has its own integrated development environment (IDE), which is a fancy name for a place where you write and test code.
JavaScript is a professional programming language that real coders use to make all sorts of things from apps to websites. You will use two easy-peasy IDEs to code in JavaScript: App Lab and MakeCode. As with the Scratch IDE, these JavaScript IDEs let you work in block mode, snapping together your coding commands. But when you feel ready to tackle text-based coding - typing your commands - you can switch to text mode in App Lab and MakeCode.
You can create your code in Scratch, App Lab, and MakeCode on any computer or tablet. Just be sure you have a good Internet connection, and you're ready to go! You learn more about the basics of working with each language and programming environment in Chapter 2.
A computer program consists of the instructions you code to make a computer do something. A program looks like a list of steps, filled with words and symbols. Many words in the list will be familiar, such as for, if, and forever. Words in a computer program are called commands because you're commanding the computer to perform some sort of action. Some commands look like combinations of words you know, smushed together into new words. For example, JavaScript uses the onEvent command to find out whether a user has pressed a button.
for
if
forever
onEvent
You might also recognize many of the symbols in a computer program. These look like operators you use in math class (+, -, >. =) and also like punctuation marks you use in English class, such as a period (.) and a semicolon (;).
All of the commands and symbols in a computer program are organized in a special order so that the computer can understand what it is supposed to do. Planning that order and then coding it is a bit like writing an essay, solving a math problem, performing dance choreography, or running a play in football. You have to put together and execute (run) the program in a specific order - you can't just put the instructions anywhere and expect the program to work correctly.
Historically, the first computer program a new coding student writes is one that prints the words "Hello World!" on the computer screen. Figure 1-1 shows an example of what that code looks like in Scratch, and its resulting output (what it displays onscreen).
Figure 1-1
Figure 1-2 shows the same code in JavaScript (in block mode and in text mode) using the App Lab IDE, and its resulting output.
Figure 1-2
Figure 1-3 shows the same code in JavaScript (in block mode and in text mode) using the MakeCode IDE, and the output when displayed on the micro:bit electronics board. Because the micro:bit can scroll only one letter at a time, the figure displays only the letter H at the beginning of "Hello World!"
Figure 1-3
You'll be making little programs like this, and much bigger programs too, in no time!
Many mornings, I cook chocolate chip pancakes for my family, following a recipe I created myself. A recipe is like a computer program, and following the recipe is like executing the program. The recipe has parts, including gathering and measuring ingredients, mixing the ingredients to make the pancake batter, and then dropping spoonfuls of the batter onto the griddle to cook it. Similarly, a computer program has parts such as asking the user for information, doing something with that information, and then telling the user the result.
Within each part of a program, you write small chunks of code to perform different processes. A chunk of code that performs a task is called an algorithm. For example, one algorithm I perform when making pancakes is testing the surface temperature of the griddle: I plug in the griddle, set it to a certain temperature, and drip a few droplets of water onto the surface to see how quickly they evaporate.
Constructing algorithms is important in coding programs to run on a computer. Think about the types of algorithms you might make in a favorite game you play on your phone. For instance, an algorithm you might code in a Yahtzee game is rolling the dice. Or an algorithm you might code in a Space Invaders game is flying a spaceship across the sky every so often.
The algorithms you create connect with each other to build your entire program. As coders, we have three fancy terms to describe how our algorithms connect: sequence, selection, and repetition. Here's what each means:
Throughout the book, you'll see references to sequence, selection, and repetition. Check back here to refresh your memory of how each is used when coding a program.
As you plan and develop your programs, you'll need to have some organized way of writing them down. You can use several methods to represent a program before you translate it into code for use on a computer.
Some people like to draw a picture or a series of pictures (called a storyboard) to show how an app, a game, or a website will look onscreen. This type of work is often performed by graphic designers, the people who make the images and the animations for computer programs. You will be doing your own graphic design work for the programs you code in this book, so think about doing a little drawing before you touch the keyboard to code.
Other people like to build a flowchart or write pseudocode when planning their programs. A flowchart is like a little map with special boxes and arrows that describe the main parts of the program. Table 1-1 shows some of the most important flowchart symbols and what each symbol...
Dateiformat: ePUBKopierschutz: Adobe-DRM (Digital Rights Management)
Systemvoraussetzungen:
Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet – also für „fließenden” Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein „harter” Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.Bitte beachten Sie: Wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!
Weitere Informationen finden Sie in unserer E-Book Hilfe.