Living Museum of Learning

Where real moments become exhibits
← Prev Next →
From a Triangle to a Canvas

From a Triangle to a Canvas

Tianjing discovers that programming ideas can travel—from Python turtle to random motion, from Python to p5.js, and even back to Swift

When Tianjing and I connected, the first thing she said was:

“Ah.”

Her Python homework was finally done.

On her screen was a beautiful little triangle made entirely with nested for loops:

*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * * *

The program was:

for r in range(7):
for _ in range(14 - 2 * r):
print(" ", end = "")
for _ in range(2 * r + 1):
print("*", end = " ")
print()

“Have you shared it?” I asked.

“Not yet.”

So she immediately posted both the code and the output to our Slack kids group and the family WhatsApp group.

She wasn't merely finishing homework anymore.

She was beginning to show her work.

I was about to move on when Tianjing stopped me.

“And this.”

I turned back.

She started explaining another change she had made to her previous homework—the details of which I had already forgotten. 😂

That was the interesting part.

She wasn't waiting for me to ask whether she had done the assignment.

She wanted to show me what she had changed.

So I got excited and asked:

“What about making the angle more random? Like, any direction?”

She immediately understood the idea.

“Sure. So 180... no, 360.”

She wrote:

randint(1, 360)

I convinced her that programmers would usually prefer:

randint(0, 359)

And suddenly her turtle program became a little experiment in randomness.

Tianjing produced:

from turtle import *
import random


speed(0)


for _ in range(300):
r1 = random.randint(0, 359)
right(r1)


r2 = random.randint(1, 100)
if r2 % 2 == 0:
fd(20)
else:
fd(10)


exitonclick()

Three hundred random turns.

A random angle from 0 through 359.

A random number determining whether the turtle moves 20 or 10 units.

Then she recorded a 9-second video of the result and shared both the video and the code.

A tiny Python program had become something worth showing other people.

And then I said:

“OK. Let's learn something new. Let's go to p5.js and do what your sister did.”

This was Tianjing's first meeting with the online canvas.

A new environment.

A new coordinate system.

A new language.

A new way to see code produce something.

Because Tianjing had become fluent enough with Python loops, she moved through the first p5.js example surprisingly quickly.

She learned to create a 400×400 canvas, draw lines, and use a loop to generate repeated horizontal lines:

for(let i = 0; i < 8; i++) {
line(20, 60 + 40 * i, 380, 60 + 40 * i)
}

The important thing wasn't that she learned another syntax.

She had already learned the underlying idea:

repeat something while changing a variable.

The language changed.

The idea survived.

And then Tianjing surprised me.

Looking at p5.js, she noticed a similarity to Swift, the language she had previously used for her iOS project.

Of course.

JavaScript's syntax is much closer to Swift than Python's syntax is.

But I loved that she noticed it herself.

She was beginning to recognize programming ideas and structures across languages.

That is a very different kind of knowledge from memorizing Python commands.

A child who begins with simple Python loops can move into randomness, visual experiments, p5.js, and eventually recognize connections with Swift.

Learn one idea deeply enough that it survives when the language, tool, and visual environment change.

Because programming fluency isn't knowing one language. It is learning to recognize the same computational ideas wearing different clothes.