I guide K-2nd graders in simple activities on code.org to learn the basics of problem solving and writing code. This 24-minute video was presented as a livestream on YouTube on March 24, 2020.
I guide K-2nd graders in simple activities on code.org to learn the basics of problem solving and writing code. This 24-minute video was presented as a livestream on YouTube on March 24, 2020.
Debugging is a method used by computer engineers to test their code and ensure they get the results they are looking for. Many programmers will spend most of their time just in debugging. Watch full video with attribution.
Algorithm is a word that sounds complex, but the application of it is very simple. An algorithm is a series of steps to complete a task. This video goes a little more in depth on the topic. Watch full video with attribution.
We like to use Scratch to help teach the basics in coding through interactive stories, games, and animations. If you’ve attended one of our courses, you’ve probably used it before. We’re going to take a moment to talk about variables and why using them will help improve your work in Scratch and any programming languages.
Variables can be just about anything, but in Scratch we typically use variables for numbers or text. Variables can do things like:
Imagine your game starting at level 1. Every time you score 5 points we want the game to “level up.” We could take the long way around and do math like 25 / 5 = 5, but that’s a lot of code to think of every possible number we would want to divide by. Variables let us set up things we want to use to make this feature of our game much easier to manage.
Open up your Scratch game and click the Data section. Click Make a Variable. Name it Score. Now repeat and make one named Level.
Step 2: Set up the game
Our game is going to be simple just to show the power of variables so we’re not going to worry about making our sprite (who should be a cat) move. We’re going to make the score go up 1 every second, and at 5 seconds we’re going to level up.
First, we need to start by setting a value for each variable. Let’s begin. You can follow along by using the images.
Step 3: Changing our first variable
We want the score to go up by 1 for each second that passes. This is done really easily.
Hit your Green Flag or GO button to watch your score go up every second. Congrats! You’re counting time!
Step 4: Level up!
Every time the Score reaches 5 we want the Level variable to go up. Essentially we’re leveling up. We’ll reset the score in this case to make it very easy to track and watch.
Last step: Reset the score
What are we missing here? We are only leveling up if we reach a Score of 5. We need to set the Score back to 0 to start the count over.
Hit your Green Flag or GO button to watch your score go up every second and your level adjust every time your score reaches 5. Congrats! You now have a way to use variables to track numbers, or data, and have an interaction happen.
Double Bonus: This program will run forever if you let it. How would we cap this at 10 levels?
Variables make a developer’s life much easier when doing complex functions and actions. It’s best practice to use variables wherever possible. This way your program becomes more flexible if you want to make little tweaks here and there. Where else could you use variables in this example we provided? Please feel free to share your projects in the comments below.
Use our Variables Example project to get started.
What If I…?
These are my favorite three words uttered by our students. My answer is almost always the same: “let’s find out.”
Computer programming gives students the unique ability to not only ponder about “what ifs”, but to immediately put them into action. What if I change the order of these code blocks? What if I change “Enderman” in this code to “EnderDragon”? (Minecraft lingo if you’re not aware) Students can make the changes, run the program, and gain instantaneous feedback to move forward.
When students ask these types of questions I know they’re on the right track. It means they’re engaged in what we’re doing. It means they’re being creative. It’s probably a good indicator of their ability to solve problems in the future.
What if I…? Do it. Let’s find out.
One afternoon, Ryan and I gave some of our curriculum a test run on our children. When you have family, it’s easy to make them the guinea pigs or test cases for what you’re trying to accomplish. We didn’t have more than an hour, and we took our kids through the Hour of Code.
The exercises found on the site are great because they’re very visual. My oldest son would add a command to the site and check what the result would be. Move forward. Great. Now we know that was the desired action or not good enough.
“I’ll just try this to see what happens,” he said.
He didn’t always get the desired result. There were several times he tried a few things, deleted the commands or started over. We talked about it for a moment, he tried again, and it started to click.
My son worked on what’s called an “if statement.” In simplest terms, think of it as “if this happens, do that.” This one was a little more complicated. It required a little more thought because there was more than one possible outcome. He had to pair two if statements together. I asked him to not look at the visual builder and look at the code itself. I asked him, “What does this code do?”
Here was his explanation:
If I can move forward. Move forward. If I can’t, then I check to see if I can turn left. If I can, I turn left. If I can’t, I turn right.
Seems like such a simple process to us because we go through these thoughts all the time in our daily lives. My son took this thought and turned it to code. What’s more impressive is he went home that day and explained it to my wife who has no coding background.
The if statement is a very logical progression of a thought. Something has to be possible for it to happen. This mode of thinking helps a child work through a problem in very simple terms. Think about conversations you had with your child. Have you ever said, “If you don’t get off that couch…” and followed it up with a consequence? This if statement helped my child to think through his own consequences when he did his Hour of Code.
My child is currently 8 years old. At 8 years old, I had no idea how to write any lines of code beyond command lines in DOS. It’s very easy to think technology or programming is a skill that doesn’t fit our children, but I see so much more potential for him because he’s already 10 years ahead of my first if statement.
We are teaching coding and computer science to children, K-12, and introduce them to new ways to problem solve and explore curiosity and creativity.