AlgoDaily

Exploring Data Using Colors and Shapes

Read at your own pace. Code execution, quizzes, progress tracking, and the AI tutor are available in the interactive view with JavaScript enabled.

Color Shape Explorer

Why this lesson matters

Now that we've covered Shapes and Patterns, Introduction to Statistics - Using Bubbles, Telling the Story with Data, and Getting To Know Probability, we are ready to look at data in a very friendly way: with colors and shapes.

Imagine a box of toy blocks:

  • red circles
  • blue squares
  • green triangles
  • yellow stars

A data scientist sees more than toys. They see clues.

Today, we will learn how colors and shapes can help us:

  • describe data clearly
  • group similar things
  • count what we see
  • notice simple relationships
  • prepare for later pattern-finding work

Tiny kid idea: Data is easier to understand when our eyes can help our brain.

Color Shape Explorer

Features Describe Things

A feature is a describing clue

In data science, a feature is one piece of information that describes something.

For a toy block, useful features might be:

Block Color Shape 1 red circle 2 blue square 3 red triangle 4 green circle

Each row is one thing we observed. Each column tells one kind of clue.

So instead of saying:

“I have some blocks.”

A data scientist says:

“I have data about blocks, and each block has features like color and shape.”

This is important because computers cannot magically understand a messy pile. We must describe the pile using clear clues.

Features Describe Things

Count Color Clues

Python can count features

In earlier lessons, Python helped us count numbers and summarize bubbles. Now Python can count categories, like colors.

A category is a label, not a measurement. For example:

  • "red" is a category
  • "circle" is a category
  • 5 could be a measurement or count

Let's count how many blocks have each color.

```python
blocks = [
    {"color": "red", "shape": "circle"},
    {"color": "blue", "shape": "square"},
    {"color": "red", "shape": "triangle"},
    {"color": "green", "shape": "circle"},
    {"color": "blue", "shape": "circle"},
    {"color": "red", "shape": "square"}
]

color_counts = {}

for block in blocks:
    color = block["color"]
    if color not in color_counts:
        color_counts[color] = 0
    color_counts[color] += 1

print("Color counts:")
for color, count in color_counts.items():
    print(color, "=", count)
```

Spot The Feature

A data scientist is describing toy blocks.

Which choice is a feature of a block?

Eyes See Groups

Colors and shapes make groups visible

When we use colors and shapes, our eyes can quickly notice groups.

Look at this tiny picture:

🔴  🔵  🔴  🟢
▲   ■   ●   ●

Even before counting carefully, you may notice:

  • some items share the same color
  • some items share the same shape
  • color and shape are separate clues

That last point matters a lot.

A red circle and a red triangle share color, but not shape. A blue square and a red square share shape, but not color.

So data can be similar in one way and different in another way.

Eyes See Groups

Make A Picture

A tiny text chart

A chart is a picture that helps tell a data story.

We do not need fancy tools yet. Python can print a simple chart using symbols.

Here, each # means one block.

```python
blocks = [
    {"color": "red", "shape": "circle"},
    {"color": "blue", "shape": "square"},
    {"color": "red", "shape": "triangle"},
    {"color": "green", "shape": "circle"},
    {"color": "blue", "shape": "circle"},
    {"color": "red", "shape": "square"},
    {"color": "green", "shape": "triangle"},
]

shape_counts = {}

for block in blocks:
    shape = block["shape"]
    shape_counts[shape] = shape_counts.get(shape, 0) + 1

print("Shape chart:")
for shape, count in shape_counts.items():
    bar = "#" * count
    print(f"{shape:8} | {bar} ({count})")
```

Color Means Amount

True or false?

If one block is red and another block is blue, that automatically means the red block is bigger.

Two Clues Together

Combining features gives richer stories

One feature can tell a small story. Two features can tell a better story.

Example questions:

  • How many blocks are red?
  • How many blocks are circles?
  • How many blocks are both red and circles?

That third question uses two clues at once.

Think of it like asking:

Is it red?    yes/no
Is it circle? yes/no

When data science and AI systems look at examples, they often use many features together. Today we are practicing with only two friendly features: color and shape.

Two Clues Together

Name The Clue

Fill in the blank.

In data science, one describing clue like color or shape is called a ______.

Ask Tiny Questions

Python can answer feature questions

Let's ask Python questions using color and shape.

We are not doing advanced AI yet. We are practicing the habit that AI needs later:

describe things clearly, then ask careful questions about the descriptions.

This example counts blocks that are both blue and circle.

```python
blocks = [
    {"color": "red", "shape": "circle"},
    {"color": "blue", "shape": "square"},
    {"color": "red", "shape": "triangle"},
    {"color": "green", "shape": "circle"},
    {"color": "blue", "shape": "circle"},
    {"color": "red", "shape": "square"},
    {"color": "blue", "shape": "circle"}
]

wanted_color = "blue"
wanted_shape = "circle"

match_count = 0

for block in blocks:
    if block["color"] == wanted_color and block["shape"] == wanted_shape:
        match_count += 1

print("Question: How many blocks are blue circles?")
print("Answer:", match_count)
```

Ready For Patterns

What you learned

Today you explored data using two friendly feature types: colors and shapes.

You learned that:

  • data items can be described with features
  • color and shape are categories
  • one item can have many features
  • Python can count categories
  • simple charts help our eyes understand data
  • combining features lets us ask better questions

This lesson connects the playful world of blocks to the serious world of data science, AI, and machine learning.

Next, we will gently move toward discovering patterns by arranging data more carefully.

Ready For Patterns

Open interactive view →