Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8074419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:38:30+00:00 2026-06-05T14:38:30+00:00

I am trying to set certain values for variables. The variables are for determining

  • 0

I am trying to set certain values for variables. The variables are for determining if a hex colour is green, red, blue, OR green and red, blue and red, or green and blue.

The value I am trying to set to determine if something is green and red vs just red or just green is to have a certain number range, in which something would be qualified as green AND red, etc…

E.G: FF0000 = Red. A1A100 = Red and Green, A1C124 = Red and Green.

My A1C124 code would have problems in my script, because it is difficult to just say

if
Red > Green or \
Red = Green and \
Red > Blue
    print red and green.

Because if that code were to run, anything that is clearly red would also come out as green and red.

So instead, I am trying to set a limit to how greater than green can red be, and vice-versa. And for that to happen, I need to set a range.

Something along the lines of:

redGreen = green +1
redGreen2 = green -1
redGreen3 = green + 2
redGreen4 = green - 2

And then I would set the code kind of like this:

if red > blue and \
   green > blue:
    redGreen = green +1
    redGreen2 = green -1
    redGreen3 = green + 2
    redGreen4 = green - 2
    print "This colour is red and green"

But there are 2 problems.

The above code does not work, as it just replaces the + 1 with the +2, and same for the negative values, and I for the life of me cannot understand any tutorials that teach me this.

So, does anyone know how to set a range? Or if there is a better method, can you explain what it is please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:38:33+00:00Added an answer on June 5, 2026 at 2:38 pm

    Admittedly, I did not manage to follow your post completely. There’s a chance, though, that converting the colour in question to HSV space and looking at the hue value only will simplify what you are trying to do.

    Python provides the function colorsys.rgb_to_hsv() to perform this conversion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having hard time trying to set certain cell's value in table. Here is
I'm trying to set up an enumeration that maps certain project-specific values to the
I am trying to loop through an array to take certain values and set
I'm trying to set a value in a QPolygonF object to a certain value.
Trying to set it so if a certain condition is met then one of
I'm trying to implement some pixel tracking where I will save certain values in
I am trying to set variables in my stored procedure when the passed parameter
I am trying to fetch the values of certain fields of a class based
I am trying to get a set of values from a one-to-many relationship for
I am trying to force users to only select certain values when adding a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.