Question: I need help making my Python 3 code to look like the turtle graphics in the below picture. This code also needs to be recursive.
I need help making my Python 3 code to look like the turtle graphics in the below picture. This code also needs to be recursive. Thanks!
This is the code that I have done:
import turtle wn = turtle.Screen() def draw_u(t, posx, posy, color): u = turtle.Turtle() u.color(color) u.penup() u.setposition(posx, posy) u.begin_fill() u.pendown() u.forward(60) u.right(90) u.forward(20) u.right(90) u.forward(60) u.right(90) u.forward(20) u.end_fill() u.penup() u.back(20) u.right(90) u.forward(20) u.begin_fill() u.pendown() u.forward(20) u.right(90) u.forward(60) u.right(90) u.forward(20) u.right(90) u.forward(60) u.end_fill() u.penup() u.right(90) u.forward(20) u.right(90) u.forward(60) u.right(90) u.forward(20) u.left(140) u.begin_fill() u.pendown() u.forward(30) u.left(40) u.forward(60) u.left(40) u.forward(30) u.left(140) u.forward(80) u.end_fill() u.penup() u.back(60) u.right(90) u.begin_fill() u.pendown() u.forward(60) u.right(90) u.forward(20) u.right(90) u.forward(60) u.right(90) u.forward(20) u.end_fill() u.penup() u.right(90) u.forward(60) u.left(90) u.begin_fill() u.pendown() u.forward(20) u.right(90) u.forward(20) u.right(90) u.forward(60) u.right(90) u.forward(20) u.right(90) u.forward(40) u.end_fill() u.right(90) u.penup() u.setposition(posx, posy) u.pendown() def draw_h(t, posx, posy, color): t = turtle.Turtle() t.color(color) t.penup() t.setposition(posx, posy) t.forward(50) t.right(90) t.forward(50) t.right(90) t.right(90) t.right(90) t.begin_fill() t.pendown() t.forward(60) t.left(90) t.forward(20) t.left(90) t.forward(60) t.left(90) t.forward(20) t.end_fill() t.penup() t.left(90) t.forward(20) t.begin_fill() t.pendown() t.forward(20) t.right(90) t.forward(60) t.right(90) t.forward(20) t.right(90) t.forward(60) t.end_fill() t.penup() t.right(90) t.forward(20) t.right(90) t.forward(60) t.right(90) t.forward(20) t.begin_fill() t.pendown() t.forward(20) t.left(90) t.forward(20) t.left(90) t.forward(60) t.left(90) t.forward(20) t.left(90) t.forward(60) t.end_fill() t.penup() t.back(40) t.right(90) t.forward(20) t.begin_fill() t.pendown() t.forward(20) t.right(90) t.forward(60) t.right(90) t.forward(20) t.right(90) t.forward(60) t.end_fill() t.penup() t.back(60) t.right(90) t.begin_fill() t.pendown() t.forward(40) t.right(90) t.forward(20) t.right(90) t.forward(60) t.right(90) t.forward(20) t.right(90) t.forward(20) t.end_fill() t.penup() t.back(20) t.left(90) t.begin_fill() t.pendown() t.forward(20) t.left(90) t.forward(20) t.left(90) t.forward(60) t.left(90) t.forward(20) t.left(90) t.forward(20) t.end_fill() t.penup() t.right(90) t.forward(60) t.left(90) t.forward(20) t.begin_fill() t.pendown() t.forward(20) t.right(90) t.forward(20) t.right(90) t.forward(60) t.right(90) t.forward(20) t.right(90) t.forward(20) t.end_fill() t.right(90) t.penup() t.setposition(posx, posy) t.pendown() def draw_Grid(t, ox, oy, rows, cols): t.ht() pathwidth, pathheight = 200, 150 for i in range(cols): posx = ox + pathwidth * i for j in range(rows): posy = oy + pathheight * j draw_u(t, posx, posy, 'black') draw_h(t, posx, posy, 'black') turtle.setup(800, 600) width, height = turtle.window_width(), turtle.window_height() t = turtle.Turtle() t.speed(6) t.ht() draw_Grid(t, 10-width//2, 230-height//2, 3, 4) turtle.done()

???? ??? ???? Transcribed image text
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
