Random Color Generation via XOR of Hex Codes

  • Share this:

Code introduction


This function generates a random color by performing an XOR operation on two hex color codes.


Technology Stack : Click

Code Type : Function

Code Difficulty : Intermediate


                
                    
import click

def random_color(arg1, arg2):
    """
    Generate a random color by combining two hex color codes.
    """
    click.echo(f"Combining {arg1} and {arg2} to get a new color")
    return f"#{int(arg1, 16) ^ int(arg2, 16):06X}"

click.echo("Random Color Generator")
click.echo(random_color("FF5733", "33FF57"))                
              
Tags: