Python Forum

Full Version: Homework help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Could anybody throw together a working program with what I have given to see if that will even work. I just tried on my desktop as well and still the same exact error
So I created a python file called useful_turtle_functions and saved it to the same folder as the file I would like to import this into.
def drawLine(x1, y1, x2, y2):
    print('drawLine called {}, {}, {}, {}'.format(x1, y1, x2, y2))

def writeText(s, x, y):
    print('writeText called {}, {}, {}'.format(s, x, y))

def drawPoint(x, y):
    print('drawPoint called {}, {}'.format(x, y))

def drawCircle(x, y, radius):
    print('drawCircle called {}, {}, {}'.format(x, y, radius))

def drawRectangle(x, y, width, height):
    print('drawRectangle called {}, {}, {}, {}'.format(x, y, width, height))
then I can do
import useful_turtle_functions

useful_turtle_functions.drawLine('x1', 'y1', 'x2', 'y2')
useful_turtle_functions.writeText('s', 'x', 'y')
useful_turtle_functions.drawPoint('x', 'y')
useful_turtle_functions.drawCircle('x', 'y', 'radius')
useful_turtle_functions.drawRectangle('x', 'y', 'width', 'height')
which gave
Output:
drawLine called x1, y1, x2, y2 writeText called s, x, y drawPoint called x, y drawCircle called x, y, radius drawRectangle called x, y, width, height
Pages: 1 2