[Tutor] writing function changeColor

Emile van Sebille emile at fenx.com
Wed Jul 18 20:05:07 CEST 2012


On 7/18/2012 10:10 AM Aditi Pai said...
> Hello,
>
> I am trying to write a function changeColor for an assignment.

I'd look in the documentation of whatever it is you're trying to change 
the color of.  It should be explained there how to set and change colors.

You're going to end up with something that could look like:

def change_color_to(new_color):
     color_of_thing = new_color

def modify_color_of_thing(by_n_pct):
     color_of_thing = old_color_of_thing * by_n_pct

where the docs of the thing you're changing provide the names and 
handling of modifying the color.

HTH,

Emile


> Two
> things that I am unsure about for this assignment are how to assign
> different colors to integers so that, red will be 1, blue will be 2,
> etc. Also, I learned python so that if I were to put in 0.9, it'd
> decrease red by 10%. The way this function needs to be written, -0.1
> decreases red by 10%
>
> Where can I find information on these two topics?
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>





More information about the Tutor mailing list