Question: python write a class color. an object is initialized with four float values. Each of these values must be between 0 and 100. If any

python write a class color. an object is initialized with four float values. Each of these values must be between 0 and 100. If any of the four arguments is not of type float, if it is negative or if it is greater than 100, an error must be raised.Class must provide

an implementation of _str_ which works as follows:

-if y=100 and all other values are 0, then "yellow" is returned

-if c=100 and all other values are 0, then "cyan" is returned

-if m=100 and all other values are 0, then "magenta" is returned

-in all other cases, a string of the form "C:10%, M:20, Y:30%, K:7%" is returned (with appopriate percentages)

an implementation of +, which works as follows: if the individual sums of the c-,m-,y-,and k- values are all less than or equal 100, they are added individually. Otherwise, a ValueError must be raised

For example, print(Color(0,10,0,0)+Color(0,80,0,0)+Color(0,10,0,0)) should output "magenta"

*Please provide written code*

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!