Only the odd and 4 integer multiples of the angle star can be drawn out, see Programs and notes:
ImportMathImportTurtle as T#This method can only be drawn at the sharp corner of the angle to draw the star, \#that is, you can use the long line segment (the longest segment length is not the turn) without mentioning the angle star of the stroke#If the note hanging 28, 29 lines, then the number of even angle to twice times, proving that this method can only draw odd and 4 integer multiples of the angle star \#that is, only the odd and 4 integer multiples of the angle star can be a stroke outdefLoop (r,n): T.FD (OL (R,n)) T.right (180-360/(N))defol (r,n): NA= (360/(4*n))/180 *Math.PI ol= R * Math.Cos (NA) * 2ol=Int (round (OL))returnoldefRelocation (r,n): T.penup () T.left (90) T.FD (R) t.right (180-360/(TheN)) T.pendown ()defMain (r,n): times=NifNinch(1,2,3,4,8): Print('cannot make a stroke out of {0:.0f} angle star'. Format (times) exit ()ifn%2==0:n/=2ifN%2==1: Print('cannot make a stroke out of {0:.0f} angle star'. Format (times) exit () relocation (r,n) forIinchRange (Times): Loop (r,n) T.penup () T.goto (0,0) t.seth (0) T.pendown () R=200N=eval (Input ('Please enter the corner number of the corner star to be drawn N:'))#eval () function is important, do not always forget to add!!!T.pensize (8)#Note that t.pensize (20) is not t.pensize=20, variable assignment takes =, property changes with T.pensize (T.color ('Green') T.speed (10) T.setup (450,450) Main (r,n) T.done ()
Pentagram and 16 Point star:
Python draws a pointed star such as a pentagram