Colors in classes was 285 lines. This version is shortened to 50 lines. I created a 2d list for the variables. I created a print and main class.
class ColorTypes:
a = b = c = d = e = f = g = ''
def choice(self, color, prisec='primary', primaryone='Red', primarytwo='None', secondaryone='None',
secondarytwo='None', complimentary='None', output='This is a primary color'):
ColorTypes.a = color
ColorTypes.b = prisec
ColorTypes.c = primaryone
ColorTypes.d = primarytwo
ColorTypes.e = secondaryone
ColorTypes.f = complimentary
class print_color(ColorTypes):
def __init__(self):
print('This is the color', ColorTypes.a)
print(ColorTypes.a, 'is a', ColorTypes.b, 'color', 'and its complimentary color is', ColorTypes.f)
if ColorTypes.b == 'primary':
print('Primary colors cannot be mixed from other colors')
if ColorTypes.b == 'secondary':
print(ColorTypes.c, 'and', ColorTypes.d, 'makes', ColorTypes.a)
if ColorTypes.b == 'tertiary':
print(ColorTypes.c, 'and', ColorTypes.e, 'makes', ColorTypes.a)
print('')
def main():
colorlist = [['red', 'primary', 'None', 'None', 'None', 'None', 'green'],
['blue', 'primary', 'None', 'None', 'None', 'None', 'orange'],
['yellow', 'primary', 'None', 'None', 'None', 'None', 'purple'],
['orange', 'secondary', 'red', 'yellow', 'None', 'None', 'blue'],
['purple', 'secondary', 'blue', 'red', 'None', 'None', 'yellow'],
['green', 'secondary', 'blue', 'yellow', 'None', 'None', 'yellow'],
['redpurple', 'tertiary', 'red', 'none', 'purple', 'None', 'yellow green'],
['orangered', 'tertiary', 'red', 'none', 'orange', 'None', 'blue green'],
['orangeyellow', 'tertiary', 'yellow', 'none', 'orange', 'None', 'blue purple'],
['yellowgreen', 'tertiary', 'yellow', 'none', 'green', 'None', 'red purple'],
['bluegreen', 'tertiary', 'blue', 'none', 'green', 'None', 'orange red'],
['bluepurple', 'tertiary', 'blue', 'none', 'purple', 'None', 'orange yellow']
]
length = len(colorlist)
ob = ColorTypes()
x = 0
while x < length:
ob.choice(colorlist[x][0], colorlist[x][1], colorlist[x][2], colorlist[x][3], colorlist[x][4],
colorlist[x][5], colorlist[x][6])
print_color()
x += 1
if __name__ == "__main__":
main()
/home/michael/PycharmProjects/colors.py/venv/bin/python /home/michael/PycharmProjects/colors.py/Color_print.py
This is the color red
red is a primary color and its complimentary color is green
Primary colors cannot be mixed from other colors
This is the color blue
blue is a primary color and its complimentary color is orange
Primary colors cannot be mixed from other colors
This is the color yellow
yellow is a primary color and its complimentary color is purple
Primary colors cannot be mixed from other colors
This is the color orange
orange is a secondary color and its complimentary color is blue
red and yellow makes orange
This is the color purple
purple is a secondary color and its complimentary color is yellow
blue and red makes purple
This is the color green
green is a secondary color and its complimentary color is yellow
blue and yellow makes green
This is the color redpurple
redpurple is a tertiary color and its complimentary color is yellow green
red and purple makes redpurple
This is the color orangered
orangered is a tertiary color and its complimentary color is blue green
red and orange makes orangered
This is the color orangeyellow
orangeyellow is a tertiary color and its complimentary color is blue purple
yellow and orange makes orangeyellow
This is the color yellowgreen
yellowgreen is a tertiary color and its complimentary color is red purple
yellow and green makes yellowgreen
This is the color bluegreen
bluegreen is a tertiary color and its complimentary color is orange red
blue and green makes bluegreen
This is the color bluepurple
bluepurple is a tertiary color and its complimentary color is orange yellow
blue and purple makes bluepurple
Process finished with exit code 0