AllTheTimeWorld.com

alice arraysArrays: Working with lists of objects

Arrays: Working with lists of objects

Learn Alice in FREE step-by-step lessons.

Module 17: Arrays: Working with lists of objects

The goal of this lesson is to learn to use arrays (lists) to act on groups of objects together.
You will learn to create an array of strings, numbers and objects.
You will learn to use the control structures that operate on arrays.

An array is a list. When you declare an array in Alice, you can select to make it an array.

The variable greeting is not an array, it is a scalar. It has a single value, "Hello World". When the tortoise says greeting, he says "Hello World"

The variable sayings is an array. The items in an array are numbered starting with 0. The number is called the index or subscript. When you use an array you need to use a subscript to specify which item, or element, in the list is to be used.

In this example, the tortoise says sayings[0], of "Ready".

An array can also use variables as the subscript:

In this example, num is 1, so when the tortoise says sayings[num] he says "Set".

In this module, you will declare and use arrays. An array is a variable that is a list.
You will create arrays of words, numbers, or objects, then use loops to process the entire array.

In order to do this you will:

Print the lesson

Please study the material at each of the links below.

  1. Arrays: Ready, Set, Go! Arrays: Ready, Set, Go!: Tortoise says "Ready", "Set", "Go" using array
    /alice/videos/alice-ready.mp4

  2. An array of animals An array of animals: An array of SJointedModel contains, yeti, tortoise and stuffedTiger
    /alice/videos/alice-array-objects.mp4
  3. The animals talk: Parallel Arrays The animals talk: Parallel Arrays: One array contains animals, the other the things they say
    /alice/videos/alice-animals-talk.mp4
  4. Who's the tallest? Who's the tallest?: People are in an array, a loop is used to find the tallest.
    /alice/videos/alice-tallest.mp4
  5. Animals counting Animals counting: An array of animals take turns to count
    /alice/videos/alice-array-counting.mp4
  6. Birds spread wings and say something Birds spread wings and say something: An array of birds perform
    /alice/videos/alice-bird-array.mp4
  7. Fish swim to cave with procedure Fish swim to cave with procedure: Each fish swims to cave with procedure
    /alice/videos/alice-fish.mp4
  8. Segments of an elephant's trunk as an array: The segments of an elephant's trunk, tail and a few other things are an array.

  9. Self Study Questions Self Study Questions: What have you learned?

  10. Discussion Questions Discussion Questions

Active Learning

Create a project using arrays