I would like to create a function using the code below called drawMove which takes 2 parameters (x or 0) and square number. That draws an x or 0 in the numbered boxes on the grid below. Input should be:
drawMove(turtle,cellsize,O,6) ---> this should draw a O in the 6th box on the grid. Anyone know how I can go about this?
""" def drawLine(t, x0, y0, x1, y1): # get t's original position x, y = t.pos() # go to the initial point t.up() t.goto(x0, y0) # draw a line to the end point t.down() t.goto(x1, y1) # return t to its original position t.up() t.goto(x,y) """ 1 3 | | | | 6 _____|_____|_____ 7 | | | | 4 _____|_____|_____ 5 | | | | (0,0). | | 0 2 Draw a TicTacToe grid, using turtle t, consisting of four lines. Draw the grid by calling function drawLine four times. Draw the grid in the upper right quadrant of the screen, so that the lower left point of the grid has coordinates (0, 0). Return t to its initial position before exiting. Each cell of the TTT grid is a square with side length size. The end points of the four lines are illustrated in the grid above. Thus, point 0 has coordinates (x0,y0). The four lines of the grid connect points 0 and 1, 2 and 3, 4 and 5, 6 and 7, respectively. Note the use below of the Python multiple assignment statement. For example, the statement a, b = 2, 3 assigns a the value 2 and b the value 3. """ def tttDrawGrid(t, size): # get t's initial position x, y = t.pos() # calculate the endpoints of the four grid lines x0, y0 = size, 0 x1, y1 = size, 3*size x2, y2 = 2*size, 0 x3, y3 = 2*size, 3*size x4, y4 = 0, size x5, y5 = 3*size, size x6, y6 = 0, 2*size x7, y7 = 3*size, 2*size # draw the four grid lines drawLine(t, x0, y0, x1, y1) drawLine(t, x2, y2, x3, y3) drawLine(t, x4, y4, x5, y5) drawLine(t, x6, y6, x7, y7) # return t to its original position t.up() t.goto(x, y)