CodeSolved

Solved Programming Questions & Exercises

Random RGB color generation

Practice Easy 2525/ Download 62 Views New

Write a function that every time a string in the formrgb()generate, so that three random numbers between 0 and 255 are placed inside the parentheses.
For example, the output may be as follows:

rgb(22, 38, 251)

1 Answers

import random

def random_rgb():
    return f"rgb({random.randint(0,255)}, {random.randint(0,255)}, {random.randint(0,255)})"
Ai Download Python New

Submit answer

Submitting answers is currently unavailable.

×
×
Close