draw stick figure in python

You can create a simple stick figure using the turtle module in Python. Here's an example code that draws a stick figure:

main.py
import turtle

# Create a turtle object
t = turtle.Turtle()

# Draw the head
t.circle(50)

# Draw the body
t.right(90)
t.forward(100)

# Draw the legs
t.right(45)
t.forward(50)
t.backward(50)
t.left(90)
t.forward(50)
t.backward(50)

# Draw the arms
t.right(135)
t.forward(50)
t.backward(50)
t.left(90)
t.forward(50)
t.backward(50)

# Hide the turtle object
t.hideturtle()

# Display the drawing
turtle.done()
409 chars
34 lines

This code uses the circle method to draw the head, and the forward, backward, right, and left methods to draw the rest of the stick figure. The hideturtle method hides the turtle object, and the turtle.done method displays the drawing.

You can customize this code and add more details to the stick figure to make it more interesting.

gistlibby LogSnag