Question: 1 . 3 . 1 1 getGreen from cmu _ cpcs _ utils import testFunction fr def getGreen ( r g b ) return 4

1.3.11 getGreen
from cmu_cpcs_utils import testFunction
fr
def getGreen (rgb)
return 42
atestFunction
def testGetGreen():
assert(getGreen (218112214)==112)
assert (getGreen (134134134)==134
assert getGreen (111019213)==19
assert getGreen (221000000)==0
getGreen (32175)==32)
)
def main():
testGetGreen()
main()
Background: We can represent colors as RGB values. That is, as 3
integers representing the amount of red, green, and blue in the color. In
this exercise, we will represent RGB values as 9 digit integers, where the
leftmost three digits represent red, the next three digits represent
green, and the last three digits represent blue. Each of the red, green,
and blue values are between 0 and 255(inclusive), where 255 is "entirely
on" and 0 is "entirely off".
For example, the RGB values of orchid (a purplish color) are 218,112,
and 214. We will represent that as the single integer 218112214.
Note that the integer does not necessarily have to be nine digits, since it
could contain leading zeroes. For example, if the RGB values are 000,
032,175, then we will represent that as the single integer 32175.
With this in mind, write the function getGreen (rgb), which takes an rgb
value as described above, and returns the integer value of the green part
of the given color. Thus, getGreen(218112214) should return 112.
 1.3.11 getGreen from cmu_cpcs_utils import testFunction fr def getGreen (rgb) return

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!