Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Color Mixer (adapted from #7) Save the file as ch3_ex2.py The colors red, blue, and yellow are known as the primary colors because they cannot

Color Mixer (adapted from #7) Save the file as ch3_ex2.py The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here:

Primary Color #1 Primary Color #2 Secondary Color Red Blue Purple Blue Yellow Green Yellow Red Orange

Write a program that prompts a user to enter two different primary colors and then shows the resulting secondary color. Your program must: Prompt the user to enter the color names (red, blue, and yellow) in lower case (because blue != BLUE != Blue) Validate that the first color entered is either red, blue or yellow Validate that the second color entered is either red, blue or yellow Validate that the same color is not entered twice Allow for the possibility that the colors are entered in reverse order (red+blue=purple, but also blue+red=purple)

Your output should be formatted like the following for valid entries:

Enter the first primary color in lower case letters: red Enter the second primary color in lower case letters: blue Color Mixer Results: red + blue = purple.

Your output should be formatted like the following for an invalid first entry:

Enter the first primary color in lower case letters: purple Enter the second primary color in lower case letters: blue Color Mixer Results: purple + blue = error: first color is invalid.

Your output should be formatted like the following for an invalid second entry:

Enter the first primary color in lower case letters: blue Enter the second primary color in lower case letters: green Color Mixer Results: blue + green = error: second color is invalid.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions