Jawaban:
import random
def generate_random_color():
# Generate random values for RGB (Red, Green, Blue)
red = random.randint(0, 255)
green = random.randint(0, 255)
blue = random.randint(0, 255)
# Format the RGB values into a color string
color = "#{:02X}{:02X}{:02X}".format(red, green, blue)
return color
# Example: Generate a random color
random_color = generate_random_color()
print("Random Color:", random_color)
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
Verified answer
Jawaban:
import random
def generate_random_color():
# Generate random values for RGB (Red, Green, Blue)
red = random.randint(0, 255)
green = random.randint(0, 255)
blue = random.randint(0, 255)
# Format the RGB values into a color string
color = "#{:02X}{:02X}{:02X}".format(red, green, blue)
return color
# Example: Generate a random color
random_color = generate_random_color()
print("Random Color:", random_color)