0 out of 464 challenges solved
Write a function `rgb_to_hsv(r, g, b)` that converts RGB color values to HSV (Hue, Saturation, Value) format. The RGB values are provided as integers in the range 0-255, and the function should return the HSV values as a tuple `(h, s, v)` where: - `h` (hue) is a float in the range 0-360. - `s` (saturation) is a float in the range 0-100. - `v` (value) is a float in the range 0-100. #### Example Usage ```python [main.nopy] print(rgb_to_hsv(255, 0, 0)) # Output: (0.0, 100.0, 100.0) print(rgb_to_hsv(0, 255, 0)) # Output: (120.0, 100.0, 100.0) print(rgb_to_hsv(0, 0, 255)) # Output: (240.0, 100.0, 100.0) ``` #### Notes - The RGB values should be normalized to the range 0-1 for calculations. - Use the formulas for converting RGB to HSV as described in the [GeeksforGeeks article](https://www.geeksforgeeks.org/program-change-rgb-color-model-hsv-color-model/).
def rgb_to_hsv(r, g, b): """ Convert RGB color values to HSV. Parameters: r (int): Red component (0-255) g (int): Green component (0-255) b (int): Blue component (0-255) Returns: tuple: (h, s, v) where h is hue (0-360), s is saturation (0-100), and v is value (0-100). """ # Normalize RGB values to the range 0-1 # Calculate the HSV values # Return the HSV values as a tuple pass