# Functions help

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Feb 24 16:01:38 CET 2014

```----- Original Message -----

> On Feb 23, 2014, at 1:44 AM, Steven D'Aprano <
> steve+comp.lang.python at pearwood.info > wrote:
> > Sorry, I don't really understand your question. Could you show an
> > example
>
> > of what you are doing?
>

> > Do you mean "add 5" or "*5"? "Add *5 doesn't really mean anything
> > to
> > me.
>
> Sorry I forgot to add the code that I had to give an example of what
> I was talking about. I’ll put it below, sorry that it’s so long. A

Here's an example of how your star() function could be rewritten.
Note that it does not exactly do what it does in your example regarding the start and end position of the turtle.
So use it for inspiration only ;)

from turtle import *
from math import sin, sqrt, radians

def star(width):
A = (2*width)/(3+sqrt(5))
# record the initial position
position = getturtle().pos()
penup()
left(36) # initial angle
forward(R)
pendown()
for arms in range(5):
left(144)
forward(A)
right(72)
forward(A)
penup()
# go back to the initial position
getturtle().setpos(position)