1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import turtle t=turtle.Turtle() s=turtle.Screen() t.speed(0) def draw_rect(x, y) : t.penup() t.goto(x, y) t.pendown() t.fillcolor('red') t.begin_fill() for n in range(4) : t.forward(50) t.left(90) t.end_fill() def draw_circle(x, y) : t.penup() t.goto(x, y) t.pendown() t.fillcolor('blue') t.begin_fill() t.circle(25) t.end_fill() def draw_triangle(x, y) : t.penup() t.goto(x, y) t.pendown() t.fillcolor('orange') t.begin_fill() for n in range(3): t.forward(50) t.left(120) t.end_fill() def draw_star(x, y) : t.penup() t.goto(x, y) t.pendown() t.fillcolor('purple') t.begin_fill() for n in range(5): t.forward(50) t.left(144) t.end_fill() def draw_shape(x, y) : if(x >= 0 and y >= 0) : draw_rect(x, y) elif(x < 0 and y >= 0) : draw_circle(x, y) elif(x < 0 and y < 0) : draw_triangle(x, y) else : draw_star(x, y) s.onclick(draw_shape) | cs |