Not Monitored
Tag not monitored by Microsoft.
39,690 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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:
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)