Aug-24-2020, 03:04 PM
Oh my this is so basic but....
I can create a 5 pointed star beautifully using a for loop. I can see different variations of star using while loops, but I want to stay with a for loop for now. I am sharing code from a trinket:
https://trinket.io/python/65aa794032
You will see that the first 2 start work well, and I thought I had the maths / coding principles, but it does not work for all variations. Can anyone see what the problem is?
I have added the code below too in case you don't want to use the trinket:
I can create a 5 pointed star beautifully using a for loop. I can see different variations of star using while loops, but I want to stay with a for loop for now. I am sharing code from a trinket:
https://trinket.io/python/65aa794032
You will see that the first 2 start work well, and I thought I had the maths / coding principles, but it does not work for all variations. Can anyone see what the problem is?
I have added the code below too in case you don't want to use the trinket:
from turtle import * star = Turtle() screen = Screen() screen.bgcolor("blue") star.speed(5) star.pu() star.goto(-75,0) star.pd() #star star.pencolor("orange") star.fillcolor('orange') star.begin_fill() for i in range(5): star.forward(200) star.right(144) star.end_fill() star.hideturtle() star.clear() #thinner longer star star.pencolor("orange") #star.fillcolor('orange') #star.begin_fill() for i in range(15): star.forward(200) star.right(168) #star.end_fill() star.hideturtle() #more points star.pencolor("orange") for i in range(20): star.forward(200) star.right(171)