The chart the program drew
Show on a big screenThe 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.
- The tally runs. Bars grow to the printed counts.
- 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.