Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color mixing
#1
When mixed, the primary colors-red, blue, and yellow- create secondary colors- orange, green and purple. mix red and blue to get purple. mix blue and yellow to get green. mix yellow and red toget orange.User needs to enter two of the primary colors. If anything other than red ,blue or yellow is entered, the program should display an error message. If they enter two of the same color, an error message should disply. Otherwise display the new secondary
Reply
#2
https://python-forum.io/Thread-Measureme...79#pid9179
Reply
#3
there is nothing under your link
Reply
#4
Quote:there is nothing under your link
(Jan-27-2017, 01:26 AM)micseydel Wrote: You can't just provide your verbatim homework and your code, outside of code tags. You need to ask a question that helps you get unblocked, and you should use code tags when you post code (and generally you should be posting code).
Reply
#5
print( "Enter two of the primary colors.")
print("red and blue", red and blue = purple)
print("blue and yellow", blue and yellow = green)
print("yellow and red", yellow and red = orange
     
     
if not red and blue or yellow:
    print("error message.")
elif two of the same colors:
    print("error message.")
else:
    print("secondary color.")
Larz60+ write Jun-09-2022, 04:50 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Please read this link: BBCode
Reply
#6
Between this thread and your other one, I can't help but think you are not putting any effort what so ever into the assignments.  If you are ignoring your instructor as much as you are ignoring the Admins and Mods on this forum, it is no wonder you are having difficulties.  Have you even tried to run the code you posted?  You need to go back and learn the basics of Python.  If your instructor is not getting the information to you, there are many many tutorials on Python, both in print and video out there and surely one of them will be presented in a way you will understand.  If your aim is to simply post an assignment and expect someone to complete it for you, then sadly, you have come to the wrong forum.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#7
This code is absolutely easy to write. The difficulty itself lies in the HEX codes, the correct code guarantees the correct display of the color. Hex codes for various colors can be found at https://create.vista.com/colors/color-names/brown/.
Reply
#8
This question has nothing to do with hex codes. It has nothing to do with color mixing. The assignment is about input verification and logic.

Your program needs to print instructions to the user and take user input. You've demonstrated you know how to print instructions. Do you know how to take user input?

Once you get user input you may need to process it to derive a result to print. Looks like you intend to do something like this:
If the two primary colors are red and blue
    print purple
else if the two primary colors are blue and yellow
    print green
else if the two primary colors are red and yellow
    print orange
else
    print error message
How do you convert this pseudo code into Python? "two primary colors" sounds like a container that can hold multiple values. Which Python types can contain more than one value?

How do you do the comparison? Are red and blue going to be the strings "red" and "blue"? What if the user types "Red" and "BLUE"? Those should be identified as primary colors. How can you make the string comparison case insensitive?

What should you do if the user enters "blue" and "blue"? These are both primary colors, and if you mix them you get blue. Should your program print "blue" or should it warn that the colors cannot be the same?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020