![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
def checkLuminance(r, g, b):
luminance=r*.3+g*.59+b*.11
print r*.3+g*.59+b*.11
if(luminance<10):
return "That's going to be awfully dark"
if(luminance>=10 and luminance<=50):
return "A little dark"
if(luminance>50 and luminance<200):
return "Looks like a good range"
if(luminance>=200 and luminance<250):
return "Getting kinda bright"
if(luminance>=250):
return "AHHH! MY EYES"
| you'd use an "and". Make sure you know how to write > and < signs on the coweb, or use code tags to put your answer in...Amanda Bennett |
| That's right. There's no picture in sight. Colin Potts |
| Strictly speaking, given the wording of the question, you SHOULD use a print in this situation instead of a return, since the question says that the function should print a message. If that's what the customer wants.... But it would be better in general to return the string as Paul suggests and have the calling function do the printing. After all, maybe we need to do something to the string before printing it, like put a tab at the beginning, turn it into upper case, concatenate the string ", Houston." on the end. Do that in the calling function, and you only have one change to make. Do it in checkLuminance and you have several changes that to make that are about formatting strings, not checking luminance. Colin Potts |
| You do not have to remember weighted averages -Albert d'Heurle |