Kids Coding

Draw with Code

Print stars, triangles, and rows. Loops make pictures out of text.

KidsBasicDraw with Code

Pictures from text

A loop can print a row of stars. Multiply a string: "*" * 5 is *****.

A row

print("*" * 5)

Change one number in the loop and the whole drawing grows or shrinks. Big art from one small tweak.

A rectangle

Four rows

for n in range(4):
    print("*" * 6)

A triangle

Let the row get longer each time. Use the loop variable.

Growing rows

for n in range(1, 6):
    print("*" * n)

Real life

Drawing a fence on a card with the same stick, over and over.

One stick, repeated. A loop prints the fence faster than you can draw it.

Garden fence

print("+" + "-" * 10 + "+")
for n in range(3):
    print("|" + " " * 10 + "|")
print("+" + "-" * 10 + "+")

Change one word. Run it. That is how this idea shows up outside the lesson.

Try it

Exercise 1: Print a triangle of # that is 4 rows tall.

Show solution
for n in range(1, 5):
    print("#" * n)

FAQ: Draw with Code

Common questions about this page.

What is StudyGrid Kids?

StudyGrid Kids is a free coding path for children: Basic, Intermediate, and Advanced. Lessons use Python in the browser. No account and no install.

Should I run draw with code examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn draw with code in this Kids Coding Python lesson (Draw with Code).

Which kids level should we start with?

Start at Basic if the child has never written code. Choose Intermediate if they can print, use variables, and write a simple if. Choose Advanced if they already use loops and lists.

Do kids need an account or an app?

No. Kids pages are public. Code runs in the Try Python editor at /try. We do not ask children for a name or an email.

What language do kids learn?

Python, with a first HTML page in Intermediate and Advanced. After Advanced, the main Python tutorial is the next step.

Is the kids coding track free?

Yes. The Kids home, the three levels, and the Python editor on StudyGrid (studygrid.in) are free.