Helping Kids with Coding For Dummies book cover

Helping Kids with Coding For Dummies

By: Camille McCue and Sarah Guthals Published: 05-08-2018

Help for grown-ups new to coding

Getting a jump on learning how coding makes technology work is essential to prepare kids for the future. Unfortunately, many parents, teachers, and mentors didn't learn the unique logic and language of coding in school. Helping Kids with Coding For Dummies comes to the rescue. It breaks beginning coding into easy-to-understand language so you can help a child with coding homework, supplement an existing coding curriculum, or have fun learning with your favorite kid.

The demand to have younger students learn coding has increased in recent years as the demand for trained coders has far exceeded the supply of coders. Luckily, this fun and accessible book makes it a snap to learn the skills necessary to help youngsters develop into proud, capable coders!

  • Help with coding homework or enhance a coding curriculum
  • Get familiar with coding logic and how to de-bug programs
  • Complete small projects as you learn coding language
  • Apply math skills to coding

If you’re a parent, teacher, or mentor eager to help 8 to 14 year olds learn to speak a coding language like a mini pro, this book makes it possible!  

Articles From Helping Kids with Coding For Dummies

page 1
page 2
page 3
24 results
24 results
Helping Kids with Coding For Dummies Cheat Sheet

Cheat Sheet / Updated 04-27-2022

Coding is fast becoming a skill that every child needs to be educated for in the 21st Century. But coding is taught at only a small fraction of schools, and often only at the high school level. Helping kids learn how to code also means you’re assisting them in developing a skill that is highly marketable and sets them apart from peers at school and later, in their careers. The topics in this cheat sheet can assist you on getting started when your kid expresses an interest in learning how to code.

View Cheat Sheet
Helping Kids with Coding: Distributing Mobile Apps

Article / Updated 06-29-2018

After you and your young coder finish making your app, you can share it with anyone who has an Android device. Just go to your list of Projects (Projects  →   My Projects), check the box next to the app you want to publish, and click Publish to Gallery. Fill out the form by uploading an image and providing a description. This is where you can put any attributions of media that you might have used in your app. Click the Publish button when you’re ready. The screen you’re taken to, after you publish your app, has a share link, which you can share with your friends who might want to check out your code. They can then click Open The App and remix it to try it on their own! To share your app with friends who just want to play your game, you have two options. Generate a temp QR code. This code allows your friends to download your app. Open your app and choose Build →   App (provide QR code for .apk). In the pop-up window is the QR code, which you can share with your friends. Using any QR code scanner, they can scan the QR code, open the link that is associated with the QR code, and a download starts. After the download is complete, they can open the app and play your game! The game is available until they delete it, even though the QR code expires in two hours. Download your app files and distribute them to your friends. You can do this by choosing Build →   App (save .apk to my computer). Then you can upload the file to Google Drive (or any other accessible server), make sure it’s accessible for anyone to view the file, and then distribute the link to the file. When your friends open the link on their Android device, the app starts downloading.

View Article
Using the MIT App Inventor to Teach Kids Coding

Article / Updated 06-29-2018

If your young coder wants to try apps, give the MIT App Inventor a try. To get started with MIT App Inventor, you need a Google account. Then follow these steps to set up your programming environment: Go to MIT App Inventor and click Create Apps in the top-right corner of the webpage. Sign in with your Google account. Give permission for Google to share your email address with App Inventor. Accept the Terms and Services for App Inventor and click Continue when you’re ready. Dismiss the survey and other items that pop up so that you can get started! You now see a view where all your projects are listed. You’re now ready to start designing and writing your first mobile app! Community and support within MIT App Inventor App Inventor was first released in 2010, and the community of coders and educators has grown. Make sure you’re signed in and then click Gallery. The image below shows the gallery where you find projects and tutorials that other coders have made and published. You and your coder can contribute to these too! In addition to the community gallery, MIT has created a number of resources for individuals and classrooms. For example, you’ll find over 30 tutorials divided by difficulty level and an option to filter by topic (such as game). There are also a ton of resources about using App Inventor, setting everything up, troubleshooting, and documentation. All this can be found in the MIT App Inventor library. Although this page is a bit less user-friendly — basically a list of links — it can be a great place to start if you have a question or experience any trouble. The community isn’t just created by MIT; there are also a number of books that you can find on App Inventor and forums where you can ask questions and get very specific answers on the App Inventor website under Resources. There are also specific resources for educators. Be sure to explore all the resources when getting your young coder acquainted with the software. The layout of MIT App Inventor Before you get started on your first mobile game, take the time to get acquainted with the programming environment. There are two areas your coder will spend time in: Design View and Code View. To get to Design View, click Start New Project in the top left of the programming environment. Name your project “myFirstApp.” The Design View opens. Note these six areas: Menu Bar: The menu bar across the top has the title of your app, options for multiple screens, and a toggle button for Designer and Blocks. Palette: On the left is a list of options for things to add to your app. Viewer: The viewer is basically what you see on your mobile device after you test your app. This is where you organize all the components to add to your app. Components: The components list shows all the elements in your app. Sometimes components are invisible, so this is an important view to know everything in your screen. Media: Under the Components view is a Media view where any sounds or images that you have uploaded to your app appear. Properties: If you click a component in the Components view, then the properties for that component is listed in this view. You can also change properties in this view, too. Then, to see the Code View, click the Blocks button on the very right of the Menu Bar. Menu Bar: Just like in the Design View, the menu bar allows you to switch screens or go back to the Design View. Blocks: This view has all the coding blocks (also referred to as tiles). There are generic blocks, but if you have a component in your design, there also are blocks specifically for that component. Media: This view has all the sounds and images that you have uploaded to your app. Coding Area: The coding area is where you drag the coding blocks to actually make your app respond to your users.

View Article
Teaching Kids Strategies for Debugging Code

Article / Updated 06-29-2018

When you and your young coder are trying to debug, sometimes no error messages give you insight into the problem. Here, you find a list of strategies for debugging programs where you don’t get an error message, or the error message doesn’t give you enough information. Turning sections on and off One of the best ways to debug is to disable sections of code so that you have small sections to test. Using Scratch In Scratch, you might have a lot of scripts that start when the green flag is pressed. This can cause problems if some of the scripts cancel out or affect the other scripts. For example, the image below shows three scripts associated with one sprite. The problem that the user notices is when the mouse pointer is touching the sprite, it does not meow. To try to figure out the problem, the coder might disconnect all the scripts and only have one script connected at a time. Then they see that the code for the mouse pointer touching the sprite works correctly, but that there is another problem (the code that stops all sounds forever). By connecting and disconnecting the blocks, the coder can identify the problem. Using App Inventor Other block-based languages like App Inventor make turning sections on and off even easier! The image below shows how if you right-click a code block, you can disable that block. In this example, you might want to make sure the initial property settings work before creating the lists and hiding the items. Then, after you confirm the properties are set properly, you can enable the call to setupLists to make sure that works. Then you can enable the call to hideItems to make sure that works. By turning off all sections and then turning each one on one at a time, it’s easier to find bugs. Using Python Text-based languages have a similar way of turning sections on and off — you only have to comment out the lines of code. In Python, you can comment out a single line of code like this: #print 'Hi' And you can comment out multiple lines of code like this: "' for x in range(0, 4): print ('Hi ' + pets[x]) "' Commenting out code is how you “turn off” or “disable” parts of your code when you’re in a text-based language. Testing sample data A common bug that coders run into is not testing data to make sure that the program works. This can especially be a problem if you’re writing programs that take user input. It’s important to make sure you and your young coder think about what kind of input you’re expecting, and test to make sure the input is handled correctly. You might have a program that gets input from the user and prints what the user types, like this Python code: name = raw_input('What is your name? ‘) print (‘Hi ' + name) It’s important to test to make sure that if you put the following types of input, they still do what you, as the coder, expect: Sarah Sarah Guthals 13 11/15 Sarah 55 Guthals By mixing letters, spaces, numbers, and other symbols like / you’re ensuring that your program performs as expected. This type of testing is unit testing and ensures that small portions of your program execute correctly with varying input. Adding output messages One of the most challenging aspects of coding is that the code is abstract and sometimes the data is hidden. This is especially tricky when you have complex data or are performing complex operations on data. By adding a number of output messages in your code, you can indicate when certain sections of code have been reached, or you can show the current values of certain variables at various points during execution. An example of adding output messages to a program to gain insight in Python follows. Here, your goal is to write a program to solve an algebraic expression. For example: x = input('Provide a number for x: ') y = input('Provide a number for y: ') first = 2*x second = 6*y sum = first - second print '2x + 6y = ' print (sum) There is an error in this program; instead of adding the first and second elements, the coder is accidentally subtracting. Though this error is fairly obvious because this example is small, it shows how a simple typo could completely change the output. If you run this code, you get results like: Provide a number for x: 2 Provide a number for y: 3 2x + 6y = -14 This is clearly wrong. 2*2 + 6*3 = 4 + 18 = 22, not -14. One way of debugging this code is to add output messages at each point. For example, you could change your code to: x = input('Provide a number for x: ') print ('x: ') print (x) y = input('Provide a number for y: ') print ('y: ') print (y) first = 2*x print ('first: ') print (first) second = 6*y print ('second: ') print (second) sum = first - second print "2x + 6y = " print sum Then, when you run the code you get the following output: Provide a number for x: 2 x: 2 Provide a number for y: 3 y: 3 first: 4 second: 18 2x + 6y = -14 Then the coder can see that x, y, first, and second are all correct. This must mean that it’s just when the sum is calculated that there is an error.

View Article
Helping Kids Find Common Coding Semantic Errors

Article / Updated 06-29-2018

It’s easy for kids to make semantic errors when they’re first learning to code. Unlike syntax errors, semantic errors are often more difficult to capture. This is because semantic errors are typically errors in the programming logic, rather than something that you typed incorrectly. Here, you find a couple of examples of semantic errors that you and your young coder might encounter in a few different programming languages. Infinite loops Infinite loops are loops that never end! They go on infinitely. This can be a problem because it might seem like the code just isn't working, but really the program is just running forever and ever. Using Java If you wrote a small Java program where you wanted to print the numbers 0 through 9, you might write something like this: for(int index = 0; index < 10; index--) { System.out.println(index); } But there is an error in this code! Instead of updating the index to be index + 1, the code updates the index to be index – 1! So the code does the following: index = 0 Is index < 10? Yes Print index 0 index = index – 1 index = -1 Is index < 10? Yes Print index -1 index = index – 1 index = -2 Is index < 10? Yes Print index -2 index = index – 1 index = -3 Is index < 10? Yes Print index -3 This continues forever, because it’s impossible for index to be greater than or equal to 10. So when you run the Java code, the program continues to print forever, until you kill the program! Using Scratch Although infinite loops can be a problem, some programming languages deliberately have implemented infinite loops to make some pretty neat effects! For example, in Scratch there is a forever block which can do some cool things. Off by one Another very common error to run into is called an off by one error. This is very common when dealing with lists and iterating through lists. Using Scratch Scratch, as usual, handles off by one errors for the user without really indicating there’s a problem. For example, the image below shows a program that loops through a list of pets and has the sprite say Hi petName, where petName is replaced with the item from the list (either Luke, Winston, or Princess). The loop repeats four times, but there are only three items in the list. Instead of completely breaking, on its last iteration, Scratch prints Hi with nothing after it. Using Python Other programming languages are not as forgiving. For example, in Python you might have the following program to say hello to the three pets: pets = ['Luke’, 'Winston', 'Princess'] for x in range(1, 3): print (‘Hi ‘ + pets[x]) If you run this program, the output would be: The reason ‘Hi Luke’ doesn’t print is because lists in Python start at 0, not at 1. The correct code would be: pets = ['Luke', 'Winston', 'Princess'] for x in range(0, 3): print ('Hi ' + pets[x]) The range function used in Python: range(0, 3) Represents the elements 0, 1, and 2 because the range function includes the first number but excludes the second. Another version of an off by one error in Python would be if you went beyond the length of the list. For example: pets = ['Luke', 'Winston', 'Princess'] for x in range(0, 4): print ('Hi ' + pets[x]) This causes even more of an issue, because instead of simply missing an element in the list, you’re trying to access an element that never existed in the first place. The output for running this code is: Hi Luke Hi Winston Hi Princess Traceback (most recent call last): File "filename.py", line 4, in print ('Hi ') + pets[x] IndexError: list index out of range There is an actual error, because the data for pets[4] doesn’t exist, so the computer cannot resolve it; therefore it doesn’t know what to do. Off by one errors can be really tricky for young coders, especially if they’re switching between languages where lists start at 1 versus lists that start at 0.

View Article
Teaching Kids to Code Subprograms with Parameters

Article / Updated 06-29-2018

Your coder can provide flexibility to her programs by coding parameters to subprograms. For example, coding a square subprogram allows the program to draw a square of a defined size each time the subprogram is called. But what if you want the square subprogram to draw squares of differing sizes? By adding a parameter to the subprogram you can do just that. A parameter is a variable that you pass into a subprogram, which the subprogram uses as it executes. You can pass a parameter into the square subprogram that tells the code how big to draw the square. Scratch code block with parameters Scratch allows you to add one or more parameters to any subprogram block you create. Your coder can begin by making a simple block. Then, your coder can add parameters when she first creates the block, or she can edit the block after it has been created — the process is essentially the same. Here are the steps for editing the square code block previously created: In the More Blocks category, right-click (Windows) or control+click (Mac) the instance code block tile that you previously created. Select Edit from the pop-up menu which appears. The Edit Block dialog box appears. At the Edit Block dialog box, click the Options tab to expand the options for adding parameters. Click the icon for any of the parameter options shown to add that parameter to your block. You can choose Add Number Input, Add String Input, Add Boolean Input, or Add Label Text. When you click an icon to add that parameter, a blank field is added to your instance code block tile. You can add more than one parameter. Inside the blank field on the instance code block tile, type the variable name of the parameter(s) you’re adding. Select the Run without Screen Refresh check box. This allows for faster execution of your program. Click OK. The dialog box closes and the code block tile now shows the added parameter(s). In Scratch, parameters added to code blocks play the same role as variables. When the parameter is added, you can use it just like a variable in your program — although be aware that it doesn’t appear in your list of variables in the Data category. Using your edited block with parameters is easy! Just drag the parameter tile from the code block definition (the big “hat” tile) into your code when you want to use the parameter. The parameter replaces code which you previously defined outright. Instead of the code tile for move 100 steps, you now have a code tile for move size steps. This allows for more flexible usage of the code block because it can now accept a number for the size, sent by the main program, and execute the code block with that size as the side length. Your main program then calls the parameterized block, sending it a number to use for the size: square 30 draws a square with side lengths of 30 pixels; square 110 draws a square with side lengths of 110 pixels. JavaScript, with parameters You can add parameters to your JavaScript functions to add flexibility to your programs. To create a function with a parameter in Code.org's App Lab, using JavaScript, complete these steps: At the Functions category of tiles, drag a function myFunction(n) tile into the program workspace. The n is a parameter. If you already added a myFunction() command without a parameter, you can add the parameter by typing the parameter inside the parentheses. (Or, if you are working in tile mode, press the little horizontal arrows to add or remove parameters from your function.) In text mode, separate multiple parameters using a comma and a space following each parameter. Replace the myFunction(n) placehoder, by typing a name for the function, and a name for your parameter(s). Use camelCase naming conventions for JavaScript. Each parameter is a variable in your program. Attach commands to define your function. The parameters are referenced by their variable names inside the function. Use the function name and parameter values to call it from your main program. The parameters values are passed into the function. Parameter values are assigned to the parameter variables and used inside the function. See the image below for a JavaScript program with functions and parameters, written in the App Lab. This program draws a field of twenty flowers of different sizes and pink color, randomly distributed in the display. Note that there are two parameterized functions: one to draw oneFlower(size), and one to draw onePetal(size) of the flower. Here, the main program calls the oneFlower(size) function that has been defined to include a size parameter. The oneFlower (randomNumber(5, 20)) function call sends a random number, from 5 to 20, to the oneFlower(size) function; size takes on a new value between 5 and 20 each time the function is called. The oneFlower(size) function then calls the onePetal(size) function. The onePetal(size) function receives whatever value its parent subprogram received for size. The effect is that flowers of different sizes are drawn onscreen. The emulator shows the result of executing the program. Java, with parameters The image below shows a Java class named Product, written in the BlueJ IDE. The class contains one method, Product, which has two parameters, a and b. Here's how to code this program: Code the class name: public class Product {. Code the main program. This is the section labeled main. The main program calls the multiply method, which receives two parameters. Code the multiply method, which has two parameters, a and b. The multiply method defines three variables, a, b, and total. Variables a and b are parameters defined as integers. Their values, 5 and 7, are received from the call located in the main program. The multiply method computes total and prints out its value. Close the class with a curly bracket. The image below shows the execution of Product. Notice that the values of the variables a and b can be changed outside of the multiply method to result in a new product for total. This makes the multiply method modular and easy to reuse with different variable values on each use. Parameterizing methods build a more flexible program. Subprograms can also generate information that they pass onto other subprograms or back to the main program. In Java, your coder sometimes sees the code void. This means that, when the subprogram is called, it's not sending anything back to the program that called it. In other cases, your coder sees a variable type and name following the name of the main program or of a subprogram. That type and name tells you what type of information is going to be received by the program making the call. The subprogram contains a return command indicating what variable value is being returned (passed back to) the program that called it.

View Article
Teaching Kids Coding: Searching Lists

Article / Updated 06-29-2018

Kids need to learn how to code all of the basics. Searching through lists is a very important task that you and your coder might want to have your program accomplish. Linear versus binary searching algorithms When it comes to lists, linear search is pretty straightforward. Essentially you start at the beginning of the list, and check to see if the first item is the item you’re looking for. If it is, you’re done! If it isn’t, you move to the next item in the list. And you repeat this sequence until you’ve either found your item, or you’ve reached the end of the list and know that your item isn’t in the list. Binary searching is a little more complicated than linear searching. Luckily, you’ve probably already used the binary search algorithm in your everyday life though. For example, when you’re looking for the word “Search” in a dictionary, you probably don’t read each word in order until you get to the word “Search.” Instead, you flip to the middle of the dictionary and check to see whether the word “Search” comes before the page you opened, or after. You know this because the dictionary is in alphabetical order! If “Search” comes after the page you’re on, you flip to a page to the right and repeat the process until you end up on the right page. This is called binary search, also known as “divide and conquer.” When writing the code for this type of search, you literally go to the middle of the list, and then the middle of the side that you know the word is on; each time dividing your search space by half. In your everyday life you might not be exactly at half, but it’s close enough to still call it a binary search. The only caveat to binary search is that the list must be sorted for the sorting to work. A linear search implementation doesn’t require your list to be sorted before searching. Common application: Finding a phone number Here, you find the code for finding a phone number in a list of names that are ordered alphabetically. This code is written in Java and, because the names are sorted but the phone numbers are not, this implementation uses the linear search algorithm. import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class sort2 { public static void main(String [] args) { Person sarah = new Person("Sarah", "555-7765"); Person camille = new Person("Camille", "555-9834"); Person steve = new Person("Steve", "555-2346"); Person rebecca = new Person("Rebecca", "555-1268"); List directory = Arrays.asList(sarah, camille, steve, rebecca); Scanner scanner = new Scanner(System.in); System.out.println("Please enter the phone number so I can tell you the name: "); String number = scanner.nextLine(); String nameFound = ""; for(int index = 0; index < directory.size(); index++) { Person personInDirectory = directory.get(index); String numberInDirectory = personInDirectory.getNumber(); if(numberInDirectory.equals(number)) { nameFound = personInDirectory.getName(); break; } } if(nameFound.equals("")) { System.out.println("Sorry, the number you are looking for does not belong to anyone in this directory"); } else { System.out.println("The number " + number + " belongs to " + nameFound); } } } This code relies on another class in a file called Person.java. The code for this file is: public class Person { String name; String number; public Person(String p_name, String p_number) { name = p_name; number = p_number; } public String getName() { return name; } public String getNumber() { return number; } }

View Article
How to Teach Kids to Code Nesting Loops

Article / Updated 06-29-2018

Nested loops can seem complicated to young coders, but they are basically a loop within a loop. This can be useful for making drawings like fractals or fun shapes that repeat but slightly change each time, creating ASCII art, or even having complex repetitions. The examples found here show how nesting loops can help create some fun programs. You can nest any kind of loop inside any other kind of loop. For example, you can nest a for loop inside a while loop! A fractal is a geometric object that has self-similarity — it shows the same pattern whether you’re looking at it far away or close up. Fractals can provide mathematically accurate models of coastlines, mountains, and other real objects from nature. Loops (specifically, recursive loops) are used to code fractals. One of the earliest uses of computer graphics in big-screen movies was the creation of fractal-based scenery for the transformation of the Genesis planet in Star Trek II: The Wrath of Khan. Khhannnnnn! Using pseudocode Nesting loops can happen in any combination. Here are some examples of nesting loops, but this list is not exhaustive. For-each loop nested inside a for-each loop: for(item in list) action1 for(item in list) action2 action3 … END_FOR_EACH action4 END_FOR_EACH Example: jellyBeanCount = 0 for(jar in jars) for(jellybean in jar) jellyBeanCount = jellyBeanCount + 1 END_FOR_EACH END_FOR_EACH While loop nested inside a for-each loop: for(item in list) action1 while(condition) action2 action3 … END_WHILE action4 END_FOR_EACH Example: for(room in house) while(wallsWhite) paintWallsBlue END_WHILE END_FOR_EACH Using Scratch Nesting loops in Scratch can be a lot of fun when you introduce the pen and start drawing fun shapes. Here are some basic examples of nesting loops in Scratch. Repeat loop nested inside a repeat loop The image below shows an example of a Scratch program that draws 10 concentric squares. The outer repeat loop is responsible for repeating 10 times for each square. The inner repeat loop is responsible for repeating 4 times, for each line and turn in each square. Repeat loop nested inside a repeat-until loop Take a look at the image below to see an example of a Scratch program that draws squares in random places around the screen until the user presses the space key. Using Python One of the most fun programs to write in Python with nested loops is ASCII art. In coding, each character and symbol that you can type on a keyboard has a number representation called its ASCII number. Although in today’s programming languages, you can type the character or symbol in your program, in the past you would have to use the ASCII number representation. ASCII art is basically when you create a picture using characters or symbols. There are some pretty amazing ASCII art examples. As a kid, Camille used to have ASCII portraits of all the Star Trek: The Original Series cast members on her wall! You can create a simple ASCII art program in Python using nested loops! For example, to create this pattern: # ## ### #### ##### ###### ####### ######## ######### The algorithm might be: Print 1 # on Row 1 Print 2 # on Row 2 Print 3 # on Row 3 … You could represent this using nested loops too! for row in range(1, 11): rowText = '' for column in range(1, row): rowText = rowText + '#' print rowText

View Article
Teaching Kids to Code Compound Conditionals (aka, AND, NOT, and OR)

Article / Updated 06-29-2018

As your young coder constructs his programs, he uses logic operations to make decisions about which code needs to execute, and under which conditions. The if-then statements he wants to construct may need to consist of more than one condition — they may need compound (multiple) conditions to execute the consequence. The main logic operations your coder uses to create compound conditional are and, not, and or. Here is what each one means: and means that every condition is true. not changes the Boolean value of a statement: true becomes false, and false becomes true. or means that at least one of the conditions is true. In pseudocode Here is the general pseudocode format of a compound conditional: if homework is done and it's after 9pm then go to bed The if portion of a compound conditional can only return a Boolean value: true or false. Here are some examples of compound conditionals in pseudocode: if (weight >= 40 lbs and height >= 38 in) then (use booster seat) if (not fuse tripped) then (electrical current flows) if (SAT > 1500 or ACT > 33) then (earn scholarship) Compound conditionals in Scratch Your coder may want to construct a Frogger-style video game, and needs to control the game action based on conditions of the game at different times. Here’s how your coder can write code for logic operations in his game. And The image below shows a portion of the game using the and operation in Scratch. The frog object has three variables — lives, timer, and y-position. When the green flag is pressed, the values of lives, timer, and y-position are set. The say command announces the Boolean value of the logic operation lives > 0 and timer > 0 Because both statements are true, the frog announces true. Not What you see below shows a new version of the game using the not operation in Scratch. When the green flag is pressed, the values of lives, timer, and y-position are set. The say command announces the Boolean value of the logic operation not touching car The value of touching car is false, so the value of not touching car is true. The frog announces true! Or The image below shows another version of the game demonstrating the or operation in Scratch. When the green flag is pressed, the values of lives, timer, and y-position are set. The say command announces the Boolean value of the logic operation touching beetle or touching butterfly The value of touching beetle is true, and the value of touching butterfly is false. So the frog announces true! Check out the image below to see a slightly altered version of the game conditions involving the or command. In this case, the beetle is no longer caught by the frog's tongue and they aren’t touching. The value of touching beetle is now false, and the value of touching butterfly is also false. So the frog announces false. In Python For young coders working in Python, compounding logical operators allow for structuring more precise control in their programs. For example, a program may be structured to compute different paychecks for people with different salaries, bonuses, and other variables. The table below shows the logical operators your young coder uses in Python. Logical Operators in Python Operator What It Means == equivalent to and and not not or or The image below shows an example of code snippet that uses logical operators in Python. The example shows code that computes different paychecks for people with different salaries, bonuses, and other variables. The code references three variables: pay, salary, and bonus, where the current value of each is pay = 50000, salary = 40000, and bonus = 10000. The code and its execution are created in pythontutor.com. In JavaScript Coders can also use logical operators in JavaScript to control the execution of their programs. This table shows the logical operators your young coder uses. Logical Operators in JavaScript Operator What It Means == equivalent to && and ! not || (double pipes) or In Java When programming in Java, young coders can — with a few exceptions — use the same logical operators shown in the table above. A key exception your coder needs to know is how to compare objects. The equality of objects should not be tested using the == operator. Instead, when trying to determine equivalence between the object values, use the .equals() method. Here is an example: name.equals("Speedy Gonzales") If the two objects are equal, the equals method returns true. Otherwise, it returns false.

View Article
Teach Kids to Code a Crypto Code Maker

Article / Updated 06-29-2018

After you and your young coder have a handle on the different math operations that are available to you in coding, it can be really fun to find ways to create fun programs that use those operations! One that doesn’t always come to mind is making a cipher! Ciphers are a lot of fun to build because they can offer additional play outside of building the program — you and your coder can write letters to each other using the secret code that only the cipher you built can solve! Building a simple crypto code maker in Scratch is actually pretty quick! The cipher built here is also known as a Caesar Cipher. Basically you give a shift amount and a letter and the program moves through the alphabet by the shift amount, looping around to A if it gets to Z, and gives you the secret letter. For example, if you wanted to tell your young coder the plaintext word “hi,” you could use a shift to move each letter to a new position in the alphabet, obscuring the original message. With a shift of 6, the plaintext, “hi” becomes the ciphertext word “NO.” It might be a good idea to play this game with a paper and pencil with your young coder before you start coding, because then you have an idea of what needs to be built! You can even have your young coder write the steps that they use to figure it out as they play with the unplugged version! To build the crypto code maker in Scratch, follow these steps: Create a list called “letters” in Scratch that contains all 26 letters. Create four variables that will keep track of the ciphertext (output), plaintext (input), shift, and position of the counter used during the algorithm. Your list and these four variables are visible under the Data category. Make sure your ciphertext, plaintext, and shift amount variables and your letters list are visible on the stage by selecting the check box next to them. Because the position variable is keeping track of the position as you iterate through the alphabet, it doesn’t have to be visible on the stage, so make sure you uncheck the box next to it. Your stage should look something like this. Ask the user for the plaintext letter and the shift amount. Be sure to save the answers from the user in the appropriate variables. Starting at position 1 in the list (A), iterate through the list of letters until you reach the letter that the user submitted. When this loop ends, the variable position holds the number that corresponds with the plaintext letter given by the user (for example, 1 is A, 2 is B, and so on). Add the shift amount to the position, then mod by 26. You have to mod by 26 to allow the cipher to start back at A if it reaches Z. For example, if the plaintext letter the user submits is X and the shift is 6, the ciphertext is D. You can evaluate this mathematically as well: X is at position 24. 24 + 6 is 30. 30 % 26 is 4. 4 is the position of letter D. Get the ciphertext letter from the list, and display it to the user. As a bonus challenge, can you have your young coder figure out how to make a reverse version of this program? See if he can build a version to convert ciphertext into plaintext!

View Article
page 1
page 2
page 3