What is colorsys.hsv_to_rgb(h, s, v) in Python?
The colorsys.hsv_to_rgb(r, g, b) function converts HSV (Hue Saturation Value) coordinates to RGB (Red Green Blue) coordinates.
Declaration
The colorsys module stores the definition of the hsv_to_rgb() function. The colorsys module can be imported using the following code:
import colorsys
colorsys.hsv_to_rgb(h, s, v)
h, s, and v can have any value between 0 and 1 inclusive.
Code
The following code snippet demonstrates the use of hsv_to_rgb():
import colorsysif __name__ == '__main__':h = 0.32s = 0.76v = 0.29r, g, b = colorsys.hsv_to_rgb(h, s, v)print('HSV:-')print('h: ' + str(h) + '\ns: ' + str(s) + '\nv: ' + str(v))print('\nRGB:-')print('r: ' + str(r) + '\ng: ' + str(g) + '\nb: ' + str(b))
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved