I would like 5 circles, one per side of the pentagon
import turtle
turtleStar = turtle.Turtle()
for s in range(5):
turtleStar.forward(100)
turtleStar.right(144)
turtleStar.left(36)
turtleStar.forward(62)
for p in range(4):
turtleStar.right(72)
turtleStar.forward(62)
for c in range(5):
r = 50
turtleStar.circle(r)
turtleStar.right(100)
CodePudding user response:
- Use one loop, draw the circles as you traverse the pentagon
- Do some math or work out on paper what you want the turtle to do (e.g. what's the exterior angle of a pentagon?)
- Make sure to read the documentation and make sure the methods you call do what you think they do
This code worked for me:
import turtle
import math
turtleStar = turtle.Turtle()
for s in range(5):
turtleStar.right(180-54)
turtleStar.circle(50/math.cos(math.pi*(90-54)/180))
turtleStar.left(180-54)
turtleStar.forward(100)
turtleStar.left(72)
CodePudding user response:
I appreciate everyones help! I got was I looking for below!
import turtle
turtleStar = turtle.Turtle()
for s in range(5):
turtleStar.forward(100)
turtleStar.right(144)
turtleStar.left(36) turtleStar.forward(62)
for p in range(4):
turtleStar.right(72)
turtleStar.forward(62)
for c in range(5):
turtleStar.right(72)
turtleStar.forward(31)
turtleStar.circle(60)
turtleStar.forward(31)