Understanding Variables in Coding – Explained for Kids

In the realm of programming, variables serve as fundamental building blocks. They are crucial components that store values and allow developers to manipulate data efficiently. Whether you’re a novice coder or an experienced programmer, grasping the concept of variables is essential for mastering any programming language. In this video, we’ll delve into the intricacies of variables, exploring their significance, usage, and practical applications.

Watch this CodeMonkey video to learn all about Variables in Computer Coding:

Read the transcript below:

Hello, welcome to Variable Valley! Let’s learn about variables.
Variables store values. The values could be numbers, strings or even objects.
Here’s a piece of code where we use a variable with the name norte, the assignment operator which is the equal sign and the value is 5.

variables screenshot 1

So 5 is stored in the variable n.
Later in the code, we could use that variable norte with a command such as the step command step n.
Since n is 5 we’re stepping 5.
So anywhere in your code where you use a number you can use a variable instead, just make sure you assign
the variable of value before you use it.

Let’s look at an example.

variables example

Here’s an example where we have three variables in the code.

norte has the value of five
and it looks like n is controlling how many times the loop goes around

x has the value of 5 and it looks like that’s how much we’re stepping each time

re has the value of 72 and that is the amount of degrees that we’re turning each time.
And if we look at the challenge you could see the monkey is stepping and turning in order to go in a circular pattern.

Okay so let’s just go ahead and run this and what’s really cool in CodeMonkey is there’s this table here that will tell you the starting value of all the variables and if they change that change will appear there as well.

Oh it looks like we need to change the value of how far it steps.
x should actually be 10
And since we change that to 10 now when we step x it’ll say what’s the value of x is 10, so you see how 10 x is 10 now.

Okay let’s look at one more example.

variables example

Now in this example you could see that the monkey is stepping in a spiral sort of pattern and first the monkey is stepping eight, turning and then stepping 12, turning, stepping 16, turning, 20, turning and 24.

How are these numbers changing each time?
Yeah it’s changing by 4 each time: 8 plus 4 is 12, 12 plus 4 is 16, and so on.
And you see how the code they’re giving us
They have re is equal to 8 so that’s the initial distance here.
And then we have a loop where we’re stepping a certain amount re
And then turning left and we’re doing that over and over again.
But we want this re to be four more each time so the way you code that is say d equals d plus four.

This is a really common way of coding a variable changing by a certain amount each time. So the way the code works it will evaluate what’s on the right-hand side.
Say what’s the current value of re? Eight.
Add four to it and then put it into the new value of re and that happens over and over again.

Also let’s just look at this code one two three four five times. I think we actually need to loop five times instead of three
so let’s go ahead and run this and remember to look at the variable table to see how it changes.

See this variable table see how re is changing? Cool.
I love having this this table!
All right, very good.
Now that we’ve reviewed variables it’s your turn to try variables!

¡Buena suerte!

Want to watch other Coding Basics Videos?

Visit the CodeMonkey Canal de Youtube.

SOBRE EL AUTOR

Pam Rissmann is a middle school STEM teacher who teaches computer science, robotics, and product design. She has been teaching for 15 years, and in addition to teaching, she coaches her school’s competitive math club and STEM Girls club. Pam is a recipient of the Santa Clara County/Texas Instruments STEM teacher award and California League of Middle School Teacher of the Year for her school. Pam was awarded by Project Lead the Way the Outstanding Gateway Teacher award in 2019.

¡Prueba CodeMonkey en casa o en la escuela!

free trial

o

para tu escuela / distrito

Más para explorar:

Meet the Teacher 2024_Brian Selke

Meet The Teacher: Brian Selke

Computer Immersion Instructional Coach | Redding, CA | Redding School District | Grades: 2nd – 8th Tell us a little bit about your

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.

Suscríbete al blog de CodeMonkey

Manténgase al día sobre las últimas noticias
Y MÁS INFORMACIÓN SOBRE CODIFICACIÓN PARA NIÑOS.