4
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by vegaseat
Featured Replies
  • 1

    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) Read More

  • 1

    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 … Read More

0

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

1

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 by woooee

0

@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 by pyTony

1

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.