COMPUTERS AND TECHNOLOGY MIDDLE SCHOOL

How to write a program converting RGB to CMYK in python

Answers

Answer 1
Answer:

rgb_scale = 255

cmyk_scale = 100

def rgb_to_cmyk(r,g,b):

if (r == 0) and (g == 0) and (b == 0):

return 0, 0, 0, cmyk_scale

# rgb [0,255] -> cmy [0,1]

c = 1 - r / float(rgb_scale)

m = 1 - g / float(rgb_scale)

y = 1 - b / float(rgb_scale)

min_cmy = min(c, m, y)

c = (c - min_cmy)

m = (m - min_cmy)

y = (y - min_cmy)

k = min_cmy

return c*cmyk_scale, m*cmyk_scale, y*cmyk_scale, k*cmyk_scale

def cmyk_to_rgb(c,m,y,k):

r = rgb_scale*(1.0-(c+k)/float(cmyk_scale))

g = rgb_scale*(1.0-(m+k)/float(cmyk_scale))

b = rgb_scale*(1.0-(y+k)/float(cmyk_scale))

return r,g,b


Related Questions

MIDDLE SCHOOL

A/an
controls the flow of data between a computer and the network.

Answers

Answer:

The NIC (Network Interface Card)  is the computer network component that controls the flow of data between a computer and the network.

Explanation:

HIGH SCHOOL

Which function of NOS involves switching the CPU time between different programs? 1.directory services

2.multitasking

3.file sharing

4.security services

Answers

The answer is (B)

Multitasking in a network operating system is the ability to execute more than one process or process at a time. Multitasking creates the appearance that multiple programs are being executed at the same time, but in reality, only one program at a time is being executed. The NOS switches the CPU time from one task or program to another in order to create the appearance that several tasks are being executed simultaneously, but in reality, only a single program is being executed

Answer:

B

Explanation:

HIGH SCHOOL

5. Which one of the following statements is true for spell checkers? A. Most spell checkers flag inappropriate word usage. B. A word you know to be correctly spelled may be flagged as misspelled. C. Spell checker dictionaries are typically larger than conventional dictionaries. D. Spell checker dictionaries include proper nouns.\ B....i think

Answers

It is b, as some word checkes don't recognize modern slangs. 
MIDDLE SCHOOL

What is a characteristic of high-level computer programming languages?

Answers

Answer:

1.The high level language are closer to human language the instruction written in this language are similar to English like words and statements

2. It is easy to understand

3. It is easy to modify

4. User friendly

5. Standarized syntax

6. Deep hardware knowledge is not required for using this.

7. Mechine indepence

8. In this language the error are easily located.

9. The program written in this language are called source code.

10. The program written in this language are shorter in size than low level language.

Random Questions