"""File: draw_taxi.py Purpose: Use TurtleWorld to draw a random walk in which the turtle always moves either vertically or horizontally Run: python draw_taxi.py Input: Delay between moves and total number of moves Output: Path followed by turtle """ from TurtleWorld import * from random import randint def move(t, nx, ny): """Move turtle t to position nx, ny Preconditions: -200 <= nx, ny <= 200 turtle is headed east Postconditions: turtle will be in position nx, ny turtle will be headed east """ dist_x = nx - t.x dist_y = ny - t.y fd(t, dist_x) lt(t) fd(t, dist_y) rt(t) world = TurtleWorld() sally = Turtle() sally.delay = float(raw_input("How long should each move take?\n ")) total_moves = int(raw_input("How many moves should the turtle make?\n ")) for i in range(total_moves): new_x = randint(-200, 200) new_y = randint(-200, 200) # new_x = int(raw_input("New x-coordinate?\n ")) # new_y = int(raw_input("New y-coordinate?\n ")) move(sally, new_x, new_y) move(sally, 0, 0) wait_for_user()