def rgb_to_cmyk(rgb_dict): rval = rgb_dict['R'] gval = rgb_dict['G'] bval = rgb_dict['B'] rprime = rval/255 gprime = gval/255 bprime = bval/255 kprime = 1-max([rprime,gprime,bprime]) cval = round(100*(1-rprime-kprime)/(1-kprime)) mval = round(100*(1-gprime-kprime)/(1-kprime)) yval = round(100*(1-bprime-kprime)/(1-kprime)) kval = round(100*kprime) return {'C':cval, 'M':mval, 'Y':yval, 'K':kval} def main(): print() while True: print("RGB To CMYK Converter") rval = input("Enter the Red Color Value (enter quit or q to quit): ") if rval == 'quit' or rval == 'q': break rval = int(rval) gval = int(input("Enter the Green Color Value: ")) bval = int(input("Enter the Blue Color Value: ")) rgb_dict = {'R':rval, 'G':gval, 'B':bval} cmyk_dict = rgb_to_cmyk(rgb_dict) cval = cmyk_dict['C'] mval = cmyk_dict['M'] yval = cmyk_dict['Y'] kval = cmyk_dict['K'] print() print("CMYK Values") print("Cyan:",cval) print("Magenta:",mval) print("Yellow:",yval) print("Key (Black):",kval) print() main()