High School Computer Science and Programming Workshop
Class 1: Lists, Sets


Hesam Samimi, Cliff Kushler
Ananda Living Wisdom School



First Program

In this class we will be learning about some Data Structures. Click on the Snap! program below and explore what it does. Try clicking on the ball, the four arrows, and the glasses:

Here is a direct link to this exercise.


Second Program

Now explore this next program. Try to find out how it behaves differently than the first one:

Here is a direct link to this exercise.


List vs. Set

Did you learn anything interesting from the two programs above?

Yes! The down arrow adds the current color to the structure, while the up arrow removes it. The first program seems to allow duplicate colors, but the second one doesn't. The structure on the first program represents a kind of data structure which is called a List. The second program represents a Set.

Can you name a few examples in real life where we would use a list? What about a few examples where using a set would be appropriate?


Data Structure Operations

Each kind of data structure, of which lists and sets are but a couple of examples, accepts a set of operations to let us work with it. You have already seen that you can add to or remove from a list or a set (using the arrow buttons in our little demo programs).

A list also lets us access the item at a particular index. We are used to using the number 1 as the first index. We'll stick with that here, but keep in mind that in programming it is more common to start from 0. You saw that clicking on the glasses button allowed us to access the item at the shown index number, if one existed.

The common operation on a set, on the other hand, is to ask whether or not an item is contained in it. That's what the glasses button seemed to show in the second demo above.

In the next class we will see a couple of other kinds of data structures.


Snap! Programming

Go ahead and play with Snap!. Click on the icon (on top of each program screen, towards the center) to explore the code. Click on each type of Sprite (shape) and select the Scripts tab to view the lego-like code for each sprite. See if you can make some sense out of them. If you feel especially daring today, go ahead and change the program, see what happens!


Next: Class 2: A Snappy Snap! Primer
Back to: Table of Contents