hi
i have been trying to draw a stick figure, but i don't know how to start, pls i need a help.

Write down how you do it yourself step by step, then write program for computer to do same.

It is very easy. Just lay it out in a list and print the list. A simplified example.

to_draw = [[" ", "O"],
           [" ", "|"],
           ["\\", " ", "/"],
           [" ", "|"],
           [" ", "|"],
           ["/", " ", "\\"]]

for each_list in to_draw:
    print "".join(each_list)

Edited 4 Years Ago by woooee

@woooee: ie:

print '''\
 O
 |
\ /
 |
 |
/ \\
'''

But if you want to change parts of it on fly list is better representation as list of strings (using splitlines method from above)

Edited 4 Years Ago by pyTony

Or you can draw using a GUI toolkit ...

# using the Zelle graphics module (derived from Tkinter)
# http://mcsp.wartburg.edu/zelle/python/graphics.py
# draw a stick figure

from graphics import *

def drawStickFigure():
    win = GraphWin("Stick figure")
    # head
    Circle(Point(100, 60), 20).draw(win)
    # body
    Line(Point(100, 80), Point(100, 120)).draw(win)
    # arms with options
    arms = Line(Point(60, 100), Point(140, 100))
    arms.setFill('red')
    arms.setWidth(10)
    arms.draw(win)
    # 2 legs
    Line(Point(100,120), Point(60,160)).draw(win)
    Line(Point(100,120), Point(140,160)).draw(win)

    # pause for click in window
    win.getMouse()
    win.close()


drawStickFigure()
This question has already been answered. Start a new discussion instead.