Learn LOGO with Real Code Examples
Updated Nov 20, 2025
Code Sample Descriptions
1
Logo Counter and Theme Toggle
make "count 0
make "isDark 0
to updateUI
print (sentence "Counter: :count)
print (sentence "Theme: (if :isDark = 1 [Dark] [Light]))
end
to increment
make "count :count + 1
updateUI
end
to decrement
make "count :count - 1
updateUI
end
to reset
make "count 0
updateUI
end
to toggleTheme
make "isDark (1 - :isDark)
updateUI
end
; Simulate actions
updateUI
increment
increment
toggleTheme
decrement
reset
Demonstrates a simple counter with theme toggling using Logo variables and procedures.
2
Logo Draw Square
to square :size
repeat 4 [forward :size right 90]
end
square 100
Draws a square using Logo turtle graphics.
3
Logo Draw Triangle
to triangle :size
repeat 3 [forward :size right 120]
end
triangle 150
Draws an equilateral triangle.
4
Logo Draw Circle Approximation
to circle :radius
repeat 360 [forward 1 right 1]
end
circle 50
Approximates a circle using small forward steps and turns.
5
Logo Spiral
to spiral :length :angle
if :length > 200 [stop]
forward :length
right :angle
spiral :length + 5 :angle
end
spiral 10 20
Draws a simple spiral pattern.
6
Logo Star
to star :size
repeat 5 [forward :size right 144]
end
star 100
Draws a 5-pointed star.
7
Logo Draw Polygon
to polygon :sides :length
repeat :sides [forward :length right 360/:sides]
end
polygon 6 80
Draws a regular polygon with N sides.
8
Logo Triangle Pattern
to triangle :size
repeat 3 [forward :size right 120]
end
repeat 6 [triangle 50 right 60]
Draws multiple triangles to form a pattern.
9
Logo Random Walk
to randomWalk :steps
repeat :steps [
forward 20
right random 360
]
end
randomWalk 50
Turtle moves in random directions to simulate a random walk.
10
Logo Colorful Spiral
to colorfulSpiral :length :angle
if :length > 200 [stop]
setpencolor random 16
forward :length
right :angle
colorfulSpiral :length + 5 :angle
end
colorfulSpiral 10 20
Draws a colorful spiral using Logo pen colors.