Skip to content
Your progress

Checking your sign-in…

Who's learning?

Each profile keeps its own read lessons, badges, streak, and practice scores on this device.

Lesson 8 of 11

The chart the program drew

Show on a big screen

6 min

Text size

The shop's crate book holds one label per crate. A label names the kind, such as tomato or onion. Seventeen labels in all. A tally turns the book into one count per kind.

Loading lab…

Six kinds, no bars yet. Every count starts at 0.
Step 1 of 3
  1. Six kinds, no bars yet. Every count starts at 0.
  2. The tally runs. Bars grow to the printed counts.
  3. One onion label is lifted out. The onion bar falls to 4.

The rule

The bars are drawn from the numbers the program printed. Change the data, and the picture follows. The picture was always just those numbers.

A bar is a column of cells. The word print shows a value on the screen. counts[0] is the count for tomato, the first kind. So print(counts[0]); prints 4. The tomato column is four cells tall. There is one cell per crate.

A kind with no crates still has a column. The column is empty, with 0 under it.

The chart shows one shop's book. It does not prove more than that.

Try the lab to finish this lesson.