Question

In: Computer Science

PYTHON PROGRAMMING The colors red, blue, and yellow are known as the primary colors because they...

PYTHON PROGRAMMING

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:

  • Red and blue = purple
  • Red and yellow = orange
  • Blue and yellow = green

For this program, you will employ list data structures to store a group of objects by designing a program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results.

Once you have completed the program, take a screen shot of the completed functionality (including the input and the output).

Also Describe your process in developing the program in detail.

Solutions

Expert Solution

Solution:

# Declaring a list of primary colors
primary_colors = ['red', 'yellow', 'blue']

# Taking input from user
c1 = input('Enter the first primary color:')
c2 = input('Enter the second primary color:')

# Checking if entered colors are primary
if not c1.lower() in primary_colors and c2.lower() in primary_colors:
    print('Error: The entered colors are not primary colors')

# Taking an appropriate decision based on inputs
else:
    if c1.lower() == c2.lower():
        print(c1)
    elif c1.lower() == 'red':
        if c2.lower() == 'blue':
            print('Mixture of these two primary colors gives us the secondary color purple')
        if c2.lower() == 'yellow':
            print('Mixture of these two primary colors gives us the secondary color orange')
    elif c1.lower() == 'blue':
        if c2.lower() == 'red':
            print('Mixture of these two primary colors gives us the secondary color purple')
        if c2.lower() == 'yellow':
            print('Mixture of these two primary colors gives us the secondary color green')
    elif c1.lower() == 'yellow':
        if c2.lower() == 'red':
            print('Mixture of these two primary colors gives us the secondary color orange')
        if c2.lower() == 'blue':
            print('Mixture of these two primary colors gives us the secondary color green')

Output:


Related Solutions

The colours red, blue, and yellow are known as the primary colours because they cannot be...
The colours red, blue, and yellow are known as the primary colours because they cannot be made by mixing other colours. When you mix two primary colours, you get one of following secondary colour: -Mix red and blue: purple -Mix red and yellow: orange -Mix blue and yellow: green Write a function colour_mix that takes two strings as parameters as two primary colours and returns the secondary colour. If the parameters are anything other than "red", "blue", or "yellow", the...
The colours red, blue, and yellow are known as the primary colours because they cannot be...
The colours red, blue, and yellow are known as the primary colours because they cannot be made by mixing other colours. When you mix two primary colours, you get one of following secondary colour: - Mix red and blue: purple - Mix red and yellow: orange - Mix blue and yellow: green Write a function colour_mix that takes two strings as parameters as two primary colours and returns the secondary colour. If the parameters are anything other than "red", "blue",...
<!DOCTYPE html> <html> <body> <script> // // The colors red, blue, and yellow are known as...
<!DOCTYPE html> <html> <body> <script> // // 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: // // When you mix red and blue, you get purple. // When you mix red and yellow, you get orange. // When you mix blue and yellow, you get green. // // Design a program...
Twelve chairs are to be painted. The available colors are Red, Blue, Green, and Yellow, and...
Twelve chairs are to be painted. The available colors are Red, Blue, Green, and Yellow, and every chair must be painted with one color. Assuming that all coloring schemes are equally likely, what is the probability that one color is not used and there are at least two chairs of every other color ? (The answer is 0.25) Can anyone explain to me why ?
Chocolates N&N come in 3 colors: blue, red and yellow. A chocolate bag should, on average,...
Chocolates N&N come in 3 colors: blue, red and yellow. A chocolate bag should, on average, be filled with 40% of blue, 40% of red and 20% of yellow. The supervisor test the machine by taking a sample of bags. He counts 85 blue, 106 red, and 43 yellow in this sample. α = 0.05 a) What are the null and alternative hypothesis? Define any necessary variables. b) What is the test statistic? c) What is the critical value or...
The distribution of M&M colors is 24% blue, 20% orange, 16% green, 14% yellow, 13% red,...
The distribution of M&M colors is 24% blue, 20% orange, 16% green, 14% yellow, 13% red, and 13% brown. You have a small bag of M&M's and count the colors. Your bag has 9 blue, 9 orange, 4 green, 12 yellow, 3 red, and 6 brown M&M's. Before you begin, how many M&M's do you need in your sample (minimum) to be able to do this test? Remember, your assumption for chi-square is that every expected frequency has at least...
Language C++ Ask the user to enter the name of one primary color (red, blue, yellow)...
Language C++ Ask the user to enter the name of one primary color (red, blue, yellow) and a second primary color that is different from the first. Based on the user's entries, figure out what new color will be made when mixing those two colors. Use the following guide: red and blue make purple blue and yellow make green yellow and red make orange If the user enters anything that is outside one of the above combinations, return an error...
Milk Chocolate M&M’s come in 6 colors; blue, orange, green, yellow, red, and brown. 1. Choose...
Milk Chocolate M&M’s come in 6 colors; blue, orange, green, yellow, red, and brown. 1. Choose your favorite color of M&M’s you will be working with for this project. State the color and give the counts below. Color of choice: Number of M&M's in your color: Total number of M&M's: Proportion of M&M's in your color: 2. Construct a 95% confidence interval for the proportion of M&M’s one can expect to find in the color of your choice. 3. Give...
What is the probability of drawing, in order, 2 red, 1 blue, and 2 yellow marbles if a bag contains 4 yellow, 5 red, and 6 blue marbles?
What is the probability of drawing, in order, 2 red, 1 blue, and 2 yellow marbles if a bag contains 4 yellow, 5 red, and 6 blue marbles?
A candy company says that the colors of its candies are 15​% ​yellow, 14​% ​red, 19​%...
A candy company says that the colors of its candies are 15​% ​yellow, 14​% ​red, 19​% ​orange, 25​% ​blue, 15​% green and 12​% brown. In a randomly selected bag of the​ candies, there were 26 ​yellow, 24 ​red, 11 ​orange, 10 ​blue, 10 ​green, 20 brown. Is this sample consistent with the​ company's advertised​ proportions? Test an appropriate hypothesis and state your conclusion. Complete parts a through g below. Fill in blanks ​a) If the​ company's candies are packaged in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT