Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Homework help
#11
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
Reply
#12
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
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020