Rocket prints the inventory dictionary for the morning meeting. The crew squints at the numbers. "Which supply is running out?" someone asks. Nobody can tell at a glance.
Raven grabs paper strips and scissors. "What do you notice about numbers? They are easier to compare as pictures." She cuts a strip for each supply, longer for bigger counts.
Nova projects a glowing bar chart in the air. "Tall bar, lots of stock. Short bar, time to restock," she says.
stock = {"water": 9, "oats": 4, "tape": 7, "lamps": 2}
for item in stock:
print(item, "#" * stock[item]) | The screen shows |
|---|
| water ######### |
| oats #### |
| tape ####### |
| lamps ## |
"#" * 9 makes a string of nine # marks. That draws a bar chart with text.
Excellent charting! Next week, your programs will start talking with the user.