question

DennisPodbicanin-4947 avatar image
0 Votes"
DennisPodbicanin-4947 asked ·

Draw the following figure with python turtle

Hello, I have to draw the following figure with turtle in python. I have achieved the following:

 import turtle
    
 turtle.speed(25)
 length = 30
 turtle.x = 25
 turtle.y = 25
 def draw_rhombus():
     for i in range(1, 3):
         turtle.forward(length)
         turtle.left(180 - 130)
         turtle.forward(length)
         turtle.left(130)
 def draw_octagon(d):
     for i in range(8):
        turtle.forward(d)
        turtle.right(360/8)
 for i in range(7):
     draw_rhombus()
     turtle.right(50)
 turtle.right(35)
 for i in range(7):
     draw_rhombus()
     turtle.right(50)
 turtle.penup()
 turtle.forward(80)
 turtle.pendown()
 turtle.right(110)
 draw_octagon(60)
    
 turtle.mainloop()

But I can't draw the second octagon. Can you help me?
Please excuse the wrong Q&A tag because I couldn't find one for the Python programming language.

Figure: 8496-download.png


not-supported
download.png (13.9 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DennisPodbicanin-4947 avatar image
0 Votes"
DennisPodbicanin-4947 answered ·

I found this solution:

 import turtle
 for i in range(12):
     for j in range(6):
         turtle.forward(80)
         turtle.left(60)
     turtle.left(30)


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.