Variables in Alice3

The goal of this lesson it to learn to use variables.
Variables allow you to store values in memory and reuse those values.
You will be able to create (declare) variables,
including how they must be named and selecting the correct data type.

In this module, you will learn about variables and how to use them.
Your program will declare variables and assign them values.
In order to do this you will:

  • Name the different types in Alice.
  • Name variables and objects correctly.
  • Declare a variable and give it an initial value.
  • Use the assign statement to give a variable a new value.
  • Select and use functions to ask the user a question and store the result.
  • Experiment with the tools available in Alice3.
  • Use constants appropriately.

Print the lesson

Please study the material at each of the links below.

  1. What is a variable?: A variable is a named location in memory.
  2. View code as Java or Alice format: Set preference to Java to match the code in the lessons.
  3. Variable types: Variables can hold strings, integers, double, Boolean or any of the gallery classes.
  4. Drill on type: See if you can select the correct type.
  5. Name of variables: Variable names must follow rules, such as no spaces.
  6. Drill on names: See if you can select the valid names.
  7. A jumping chicken: Use a variable for the amount to jump, use it to move up and down.
  8. Assign: giving a new value to a variable: The assign statement is used to give a variable a new value.
  9. Using constants: A constant never changes. Its name is usually all uppercase.
  10. Discussion Questions

Active Learning

Use variables

Like us on Facebook:

OER: Open Educational Resource
Creative Commons License Author: Janet E. Joy; Publisher:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Creative Commons Attribution-NonCommercial 4.0 International License
Last modified: May 17 2017 16:50:11.