Python Labs¶
Interactive Python labs that run directly in your browser — no account or install needed. Each lab uses Skulpt to run real Python code with turtle graphics right on the page.
-
Turtle Commands
Learn the core commands that move, turn, and color the turtle — the building blocks of every drawing in this course.
-
Drawing a Square
Give the turtle its first drawing commands and watch a square appear using
forward()andright(). -
Variables for Your Drawing
Store distance and angle in variables so you can resize the whole square by changing just one number.
-
Drawing Polygons with Loops
Use a
forloop and the 360/sides angle formula to draw any regular polygon with just 9 lines of code. -
Drawing a Stop Sign
Combine variables, a
forloop, andbegin_fill()/end_fill()to draw a filled red octagon with STOP text. -
Changing Colors with If-Else
Use
if/elseand the modulo operator%to draw a square with automatically alternating side colors. -
Functions and Flowers
Define a
petal()function and call it in a loop to grow a full flower on the canvas. -
Function Parameters: Four Colored Squares
Add color and position parameters to a
square()function and call it to place shapes anywhere on the canvas. -
Random Circles
Use
random.randint()to scatter 10 colorful circles at unpredictable positions — a different picture every run. -
Color Lists
Create a list of colors, access items by index, and loop through the whole palette to paint a rainbow row of circles.
-
Random Stars
Write a
star()function and call it with random positions, sizes, and colors to fill the canvas with star art. -
Reading Output and Error Messages
Learn to tell apart black output and red errors, and use
print()checkpoints to hunt down bugs. -
Getting Input from the User
Use
input()andint()to let the user decide how many shapes to draw while the program is running. -
Fractal Tree with Recursion
Write a function that calls itself to draw a branching tree — each branch spawning two smaller branches.
-
Hex Colors and Styled Text
Use six-digit hex codes to access millions of colors and write bold, italic, and large text on the canvas.
-
Plotting a Sine Wave
Import
math, loop through x values, and usegoto()to plot a smooth sine curve across the canvas. -
Responding to Mouse Clicks
Register a click handler with
onscreenclick()and draw a colored circle wherever the user clicks.