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.
- What is a variable?: A variable is a named location in memory.
- View code as Java or Alice format: Set preference to Java to match the code in the lessons.
- Variable types: Variables can hold strings, integers, double, Boolean or any of the gallery classes.
- Drill on type: See if you can select the correct type.
- Name of variables: Variable names must follow rules, such as no spaces.
- Drill on names: See if you can select the valid names.
- A jumping chicken: Use a variable for the amount to jump, use it to move up and down.
- Assign: giving a new value to a variable: The assign statement is used to give a variable a new value.
- Using constants: A constant never changes. Its name is usually all uppercase.
- Discussion Questions
Active LearningUse variables
Like us on Facebook:
OER: Open Educational Resource
Author: Janet E. Joy; Publisher: Zebra0.com
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.