vendredi 21 février 2014

Re: Function and turtle help topic





On Feb 21, 2014, at 7:13 PM, Dave Angel <(E-Mail Removed)> wrote:

> Scott W Dunning <(E-Mail Removed)> Wrote in message:
>>
>> On Feb 20, 2014, at 11:30 PM, Dave Angel <(E-Mail Removed)> wrote:
>>
>>> Look at turtle.begin_fill and turtle.end_fill
>>>
>>> That's after making sure your star is a closed shape.

>>
>>
>>
>> So, this is what I have so far and it “works” but, it fills in the star with black and as you can see below I am trying to fill it in with red. So I’m obviously messing up somewhere.
>>
>> def fillcolor(red):
>> pencolor()
>> begin_fill()
>> star(500)
>> end_fill()
>>
>> red = pencolor
>> fillcolor(red)
>>

>
> You seem to have a fundamental misunderstanding of how variables
> and function parameters work.


Yes I just learned a little bit about functions a couple days ago in school. I am completely new to programming so thanks for any help!

>
>> def fillcolor(red):

> The parameter should be something like color, not red.


Ok I see.

I changed it a little based on what you suggested and I got a change, the outline became red but the fill is still black. Can you walk me through where I’m going wrong on what I have below?

From what I gather, I have a function called fillcolor with a parameter called color. I know this is going to sound stupid but I get a little lost after that. The function says when ever I call fillcolor do what’s in the body? What exactly does the parameter do (in this case color, how is that doing anything) and what is an argument?

def fillcolor(color): <- Function with parameter, right?
pencolor(color) <- Says make pencolor whatever I state when I call fill color, right?
begin_fill() <- starts filling the star. When I put color in () though I get an error that it takes no arguments?
star(500) <- Star function
end_fill() <- Ends fill

red = "red"
fillcolor(red)


I know that I know absolutely nothing but I’m trying and I just started so please bare with me. And thanks for any help, it's GREATLY appreciated!!

Scott








Aucun commentaire:

Enregistrer un commentaire