Posts: 10
Threads: 3
Joined: Oct 2016
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
Posts: 2,168
Threads: 35
Joined: Sep 2016
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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
1 2 3 4 5 6 7 |
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
|