Computer programs use variables to store information.
Variables could be used to store the score in a game, the number of cars in a car park or the cost of items on a till. They work in a similar way to algebra, where a letter in your code can stand for a number.
Through informational text and video, students will explore many ways computers use variables.
Variables are used as placeholders for values such as numbers or words. Variables allow for a lot of freedom in programming. Instead of having to type out a phrase many times or remember an obscure number, computer scientists can use variables to reference them. This lesson helps to explain what variables are and how we can use them in many different ways. The idea of variables isn't an easy concept to grasp, so we recommend allowing plenty of time for discussion at the end of the lesson.
Variables are very helpful in programming. Students will be introduced to this topic using envelopes to represent variables that have been given names. The value of the variable will be written on a card placed inside an envelope. This lesson helps students understand how names can be a placeholder for values in the physical world so that programming with variables will seem less confusing in the virtual world.
Students will be able to:- identify variables and determine their values.- define and call variables in the context of real-life activities.- create situations which require the use of variables.
Note: You will need to create a free account on code.org before you can view this resource.
In this lesson, students will explore the creation of repetitive designs using variables in the Artist environment. Students will learn how variables can be used to make code easier to write and easier to read, even when the values don't change at runtime. This stage teaches the most basic use for variables, as a constant that reoccurs frequently in a program.
Students will be able to:- assign values to existing variables.- utilize variables in place of repetitive values inside of a program.
This lesson will help illustrate how variables can make programs more powerful by allowing values to change while the code is running. You don't always know what a value is going to be before you begin your program. Sometimes, values change while your code is running. This lesson will illustrate how code with changing values can be helpful.
Students will be able to:- identify areas where they can use variables to modify quantities during runtime.- examine code to find places where variables can be substituted for specific values.
In this lesson, students will explore the creation of repetitive designs using variables in the Artist environment. Students will learn how variables can be used to make code easier to write and easier to read. After guided puzzles, students will end on a free play level to show what they have learned and create their own designs.
Variables are essentially placeholders for values that might be unknown at the time that you run your program or for values that can change during the execution of a program. These are vital to creating dynamic code because they allow your program to change and grow based on any number of potential modifications. This stage reinforces the use of variables, using the most basic capabilities of setting and using them.
Students will be able to:- assign values to existing variables.- utilize variables in place of repetitive values inside of a program.- use variables to change values inside of a loop.
We know that loops allow us to do things over and over again, but now we’re going to learn how to use loops that have extra structures built right in. These new structures will allow students to create code that is more powerful and dynamic.
At this point, students have become masters of loops. Today, they will learn about another loop commonly used in programming. The for loop repeats commands a certain number of times but also keeps track of the values it is iterating over. For example, a for loop that begins at 4, ends with 8, and has a step value of 1 will repeat 4 times, but the values 4, 5, 6, and 7 will also be captured for use elsewhere. Using this structure with variables can create some pretty fantastic programs. Today, students will simply be learning the basics of a for loop before diving into programming with them next time!
Students will be able to:- determine starting value, stopping value, and stepping value for a `for` loop.- illustrate the counter values hit each time through a for loop during runtime.
Featuring Bee, this lesson focuses on for loops and using an incrementing variable to solve more complicated puzzles. Students will begin by reviewing loops from previous lessons, then they'll walk through an introduction to for loops so they can more effectively solve complicated problems.
Today's concept, for loops, are a very important topic in computer science. Not only are they widely used, but the process of learning for loops enhances the learning of other important concepts (such as variables and parameters). Students will have plenty of practice critically thinking through problems by determining the starting, ending, and stepping values for each for loop. This concept uses plenty of math as well, so feel free to pair it with a math lesson for an even deeper learning experience.
Students will be able to:- determine starting value, stopping value, and stepping value for a `for` loop.- recognize when to use a `for` loop and when to use other loops such as `repeat` and `while` loops.
In this lesson, students continue to practice for loops, but this time with Artist. Students will complete puzzles combining the ideas of variables, loops, and for loops to create complex designs. At the end, they will have a chance to create their own art in a free play level.
Creativity and critical thinking come together beautifully in this lesson. Students will continue their practice with for loops and variables while they create jaw-dropping images. This lesson inspires a creative mind while teaching core concepts to computer science.
Students will be able to:- use `for` loops to change loop several times with different values.- recognize when to use a `for` loop and when to use other loops such as `repeat` and `while` loops.